我正在使用 chrome 存储 API 来保存需要在内容脚本页面上访问的数据。当我像这样在扩展设置页面中加载数据时
document.write("chrome.storage.sync.get(\"password\", function(items) {\n");
document.write("var true_password = items.password;\n");
document.write("});\n");
它有效,但相同的代码不适用于内容脚本......
我收到此错误
未捕获的类型错误:无法读取未定义的属性“同步”
知道为什么吗?
编辑
manifest.json
{
"name":"app",
"description":"app...",
"version":"0.1",
"manifest_version":2,
"options_page": "options.html",
"permissions": [ "storage" ],
"content_scripts": [
{
"matches": ["https://www.my_page.com/*"],
"js": ["lock.js"]
}
]
}