Mozilla Addon SDK - Possible to save changes programmatically via simple-prefs?

StackOverflow https://stackoverflow.com/questions/22698449

  •  22-06-2023
  •  | 
  •  

Вопрос

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