[英]How to save options using chrome.storage.sync?
I wanna use chrome.storage.sync
where I link the script file at the options page, but chrome.*
is not available in content scripts , how will I be able to utilize chrome.storage.sync
? 我想在选项页面上链接脚本文件的地方使用chrome.storage.sync
,但是内容脚本中没有 chrome.*
,我将如何利用chrome.storage.sync
?
<!-- options.html -->
<head>
<script src="options.js"></script><!-- chrome.storage.sync not available -->
</head>
<body>
....
As mentioned in the docs on chrome.storage
: 如chrome.storage
文档中chrome.storage
:
(Through
chrome.storage
...) your extension's content scripts can directly access user data without the need for a background page (通过chrome.storage
...)您扩展程序的内容脚本可以直接访问用户数据,而无需后台页面
So, a content script does have access to the storage
API and this very fact is actually one of its advantages against localStorage
. 因此,内容脚本确实可以访问storage
API,而这实际上是它相对于localStorage
优势之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.