如何同步 FF simple-prefs
How to sync FF simple-prefs
我想使用 require('sdk/preferences/service')
同步我的 Firefox 插件的设置。
这是我的非工作试用版:
package.json:
{
"title": "Test",
"name": "test",
"author": "devname",
"version": "1.0.0",
"main": "lib/main.js",
"engines": {"firefox": ">=38.0a1","fennec": ">=38.0a1"},
"license": "MPL-2.0",
"id": "test@devname.org",
"permissions": {"private-browsing": true},
"dependencies": ["addon-kit"],
"preferences": [{
"title": "Color 1",
"type": "color",
"value": "#000000",
"name": "1"
}]}
lib/main.js:
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);
simprefs.on('1', function() {
simprefs.prefs["syncy"] = simprefs.prefs["1"];
});
})();
因此,当我在 Addon-Manager 中将 pref 1 设置为颜色 #777777 时,pref syncy 将获得相同的值(在 about:config 页面上可见)。
当我使用 2 个 Firefox 配置文件并向 Mozilla 注册以进行同步并在每个配置文件上安装此附加组件时,我希望在一个配置文件上更改此值会在另一个配置文件上更改它(因此 about:config 上的设置 -> extensions.test@devname.org.syncy) - 但事实并非如此。
我做错了什么?
来自 Mozilla Wiki 关于在配置文件之间同步加载项的条件:
Currently, Sync will synchronize add-ons that meet the following criteria:
- Is an extension or theme (i.e. not a plugin)
- Is installed in the profile directory
- Is installed explicitly by the user inside of Firefox
- Is installed from a trusted URI
我认为问题在第四个条件。在开发期间,Firefox 不能信任您的插件。但在同一篇文章中,暗示了绕过第 4 个条件的可能变体:
Why is Functionality Limited to Add-ons from addons.mozilla.org?
First, this is only the default behavior. The services.sync.addons.trustedSourceHostnames preference is a comma-delimited list to allow other trusted hostnames.
我想使用 require('sdk/preferences/service')
同步我的 Firefox 插件的设置。
这是我的非工作试用版: package.json:
{
"title": "Test",
"name": "test",
"author": "devname",
"version": "1.0.0",
"main": "lib/main.js",
"engines": {"firefox": ">=38.0a1","fennec": ">=38.0a1"},
"license": "MPL-2.0",
"id": "test@devname.org",
"permissions": {"private-browsing": true},
"dependencies": ["addon-kit"],
"preferences": [{
"title": "Color 1",
"type": "color",
"value": "#000000",
"name": "1"
}]}
lib/main.js:
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);
simprefs.on('1', function() {
simprefs.prefs["syncy"] = simprefs.prefs["1"];
});
})();
因此,当我在 Addon-Manager 中将 pref 1 设置为颜色 #777777 时,pref syncy 将获得相同的值(在 about:config 页面上可见)。
当我使用 2 个 Firefox 配置文件并向 Mozilla 注册以进行同步并在每个配置文件上安装此附加组件时,我希望在一个配置文件上更改此值会在另一个配置文件上更改它(因此 about:config 上的设置 -> extensions.test@devname.org.syncy) - 但事实并非如此。
我做错了什么?
来自 Mozilla Wiki 关于在配置文件之间同步加载项的条件:
Currently, Sync will synchronize add-ons that meet the following criteria:
- Is an extension or theme (i.e. not a plugin)
- Is installed in the profile directory
- Is installed explicitly by the user inside of Firefox
- Is installed from a trusted URI
我认为问题在第四个条件。在开发期间,Firefox 不能信任您的插件。但在同一篇文章中,暗示了绕过第 4 个条件的可能变体:
Why is Functionality Limited to Add-ons from addons.mozilla.org?
First, this is only the default behavior. The services.sync.addons.trustedSourceHostnames preference is a comma-delimited list to allow other trusted hostnames.