我正在爲自己的用途創建一個擴展,但我遇到了問題。我想爲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";