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..

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top