前manifest.json
{
"manifest_version": 3,
"name": "XXXX",
"version": "1.0",
"background": {
"service_worker": "background.js"
},
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["content.js"]
}],
"permissions": [
"activeTab",
"storage",
"scripting",
"webRequest"
],
"action": {
"default_popup": "pages/popup.html",
"default_icon": {
"16": "img/yq120.png",
"32": "img/yq120.png",
"48": "img/yq120.png",
"128": "img/yq120.png"
}
}
}
当执行background.js中的事件时,会报错如下
Cannot access contents of the page. Extension manifest must request permission to access the respective host
得在manifest添加访问标签页时,background.js执行的权限
改良后manifest.json
{
......
"host_permissions": ["http://*/*", "https://*/*"],
......
}
现在即可在访问标签页且无需点击插件 就能在background.js中执行
606

被折叠的 条评论
为什么被折叠?



