Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you sync firefox addon/extension preferences?

What is the format for declaring that an addon's preferences should sync across firefox installations? I see a short description that you should create services.sync.prefs.sync.extension.frobnaz.foobar but how should that be entered in the package.json that defines the addon's preferences? For instance, say I've defined a preference there:

"preferences": [{"name": "show_xyz",
                 "type": "bool",
                 "title": "Show XYZ",
                 "value": true}]

In firefox's about:config this is ultimately translated into the preference extensions.<addon id>@jetpack.show_xyz. So how should services.sync.prefs.sync.* preferences be created?

like image 727
Ralf Haring Avatar asked Nov 10 '22 08:11

Ralf Haring


1 Answers

You have to deal with this programmatically, through the preferences/service module.

var ps = require('sdk/preferences/service');
var addonid = require('sdk/self').id;

var simpleprefs = ps.keys('extensions.' + addonid);

simpleprefs.forEach(function(prefname){
  ps.set('services.sync.prefs.sync.extensions.' + addonid + '.' + prefname, true)
});
like image 161
paa Avatar answered Dec 28 '22 12:12

paa