Question

Is it possible to update a firefox addon's preferences programmatically?

Given the following:

const prefs = require("sdk/simple-prefs");
prefs.stringPreference = "some random string";

It seems that my update to stringPreference doesn't get persisted, and will revert back to the value in about:addons when reloaded, new tabs are opened, etc.

Is this possible? The docs imply changes are saved automatically but this doesn't seem to be the case..

Était-ce utile?

La solution

You have missed the .prefs attribute. It should be:

var prefs = require("sdk/simple-prefs").prefs;

Notice the .prefs at the end of the line.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top