chrome.tabs
尽管我在权限块中设置了选项卡,但仍返回未定义。
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"js/myScript.js"
],
"all_frames": true
}
],
But in myScript.js
, chrome.tabs
is undefined
.
内容脚本只能使用chrome。i18n
, 铬合金。dom
, 铬合金。storage
,以及 chrome 的子集。runtime
/chrome.extension
.
Most chrome
API 例如chrome.tabs
仅适用于后台脚本(MV3 中的 Service Worker)、弹出脚本等。
Solution
传递消息从内容脚本到后台脚本并使用那里的 API。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)