我正在为自己的用途创建一个扩展,但我遇到了问题。我想为background.js至content.js分配一个变量值。尽管刷新了内容页面,但始终存在background.js的变量。这个怎么做?如何从内容脚本访问后台脚本变量
的manifest.json
{
"manifest_version": 2,
"name": "Slownik",
"version": "1.0",
"description": "Slownik",
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["*://*.sjp.pl/*"],
"js": ["content.js"]
}
]
}
background.js:
var test = "test";
content.js:
test = "testA";