Google chrome extension 是否可以在安装之间以某种方式保留web扩展设置?
我需要经常安装/卸载我的web扩展(用于Chrome和Firefox),我希望在安装之间保留一些开发人员设置,以避免每次新安装后不断重新输入设置Google chrome extension 是否可以在安装之间以某种方式保留web扩展设置?,google-chrome-extension,firefox-addon,firefox-addon-webextensions,Google Chrome Extension,Firefox Addon,Firefox Addon Webextensions,我需要经常安装/卸载我的web扩展(用于Chrome和Firefox),我希望在安装之间保留一些开发人员设置,以避免每次新安装后不断重新输入设置 我尝试使用web扩展,但所有保存的数据都会在web扩展卸载时自动删除。也许还有其他方法可以做到这一点?在Firefox上,卸载并重新安装扩展后,存储在storage.sync中的值是可读的。即使您没有设置Firefox Sync,它也是可用的。例如: manifest.json: { "name":"foo", "version":"1",
我尝试使用web扩展,但所有保存的数据都会在web扩展卸载时自动删除。也许还有其他方法可以做到这一点?在Firefox上,卸载并重新安装扩展后,存储在
storage.sync
中的值是可读的。即使您没有设置Firefox Sync,它也是可用的。例如:
manifest.json:
{
"name":"foo",
"version":"1",
"manifest_version": 2,
"background": {
"scripts": ["background.js"]
},
"permissions": ["storage"],
"browser_specific_settings": {
"gecko": {
"id": "counter@example.com", <= this is required to keep values after reinstalling
"strict_min_version": "68.0"
}
}
}
{
“名称”:“foo”,
“版本”:“1”,
“清单版本”:2,
“背景”:{
“脚本”:[“background.js”]
},
“权限”:[“存储”],
“特定于浏览器的设置”:{
“壁虎”:{
“id”:”counter@example.com", {
console.log('count:',result.foo);没有这样的API。您可以稍后再导入。设置是否需要安全?如果其他扩展可以读取这些设置,是否可以?谢谢,但我需要两种浏览器的解决方案,所以看起来我需要重新考虑我的需要并找到其他东西。
chrome.storage.sync.get({ foo: 0 }, result => {
console.log('count: ', result.foo); <= You will see this value is kept and increased even after you reinstall this extension.
chrome.storage.sync.set({ foo: result.foo + 1 });
});