I would like to make addon settings and other stored user data syncable.
Tried the following:
- Define a syncable pref:
const
addonid = require(‘sdk/self’).id,
simprefs = require(‘sdk/simple-prefs’),
simstore = require(‘sdk/simple-storage’),
service = require(‘sdk/preferences/service’),
store = simstore.storage
;
service.set(‘services.sync.prefs.sync.extensions.’ + addonid + ‘.syncy’, true); - Reflect changes of the storage to this pref:
simprefs.prefs[“syncy”] = JSON.stringify(store); - Listen to changes on this pref for updating the storage:
simprefs.on(‘syncy’, function() {
store = JSON.parse(simprefs.prefs[“syncy”]);
});
On about:config it looks fine:
services.sync.prefs.sync.extensions.test@myName.org.syncy;true
extensions.test@myName.org.syncy;{…}
But still syncing doesn’t work.
Also, when I open either a new temporary Firefox profile from the console with jpm run -b /usr/bin/firefox or another existing profile with firefox -P mySecondProfileName I get the following incomprehensible message in the console:
1461668786772 addons.xpi WARN Exception running bootstrap method startup on {fe272bd1-5f76-4ea4-8501-a05d35d823fc}: ReferenceError: invalid assignment left-hand side (resource://gre/modules/addons/XPIProvider.jsm → jar:file:///home/mcl/.mozilla/firefox/c9wvycuh.syncy/extensions/%7Bfe272bd1-5f76-4ea4-8501-a05d35d823fc%7D.xpi!/bootstrap.js → jar:file:///home/mcl/.mozilla/firefox/c9wvycuh.syncy/extensions/%7Bfe272bd1-5f76-4ea4-8501-a05d35d823fc%7D.xpi!/lib/ui.js:407:5) JS Stack trace: require@bootstrap.js:141:4 < @main.js:19:1 < require@bootstrap.js:141:4 < startup@bootstrap.js:28:2 < this.XPIProvider.callBootstrapMethod@XPIProvider.jsm:4658:9 < this.XPIProvider.startup@XPIProvider.jsm:2728:13 < callProvider@AddonManager.jsm:227:12 < _startProvider@AddonManager.jsm:833:5 < AddonManagerInternal.startup@AddonManager.jsm:1016:9 < this.AddonManagerPrivate.startup@AddonManager.jsm:2782:5 < amManager.prototype.observe@addonManager.js:58:7
Thanks a lot for any help