chrome.storage.sync undefined?

最后都变了- 提交于 2019-11-27 19:36:49

You have to add the "storage" permission in your manifest.json file, i.e.:

...
  "permissions": [
    "storage"
  ],
...

For more information, see: https://developer.chrome.com/extensions/storage

Reload the Extension

I had the "permissions" key added in my manifest file but still I struggled to get this fixed.

After adding the permission:-

"permissions": [
    "storage"
 ]

Goto your extension using: chrome://extensions/ & click the Reload button:-

kabeleced

If someone was facing this issue on Firefox, please note, that it is not supported yet:

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage#Chrome_incompatibilities

For my purposes it was sufficient to replace chrome.storage.sync by chrome.storage.local.

Regarding the Firefox implementation state it might be worth to look also here from time to time:

http://arewewebextensionsyet.com/#storage

See https://developer.chrome.com/extensions/content_scripts.html:

However, content scripts have some limitations. They cannot:

Use chrome. APIs (except for parts of chrome.extension)*

(emphasis added)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!