Javascript 无法使用任何Chrome API来监听事件
当然,这个问题太疯狂了,但我找不到任何解决办法 我的代码的详细信息: manifest.jsonJavascript 无法使用任何Chrome API来监听事件,javascript,google-chrome-extension,google-chrome-devtools,Javascript,Google Chrome Extension,Google Chrome Devtools,当然,这个问题太疯狂了,但我找不到任何解决办法 我的代码的详细信息: manifest.json "content_scripts": [{ "js": [ "ct.js" ], "matches": [ "<all_urls>" ] }], "permissions": [ "management","storage","proxy", "*://*/*" ], 我在控制台中得到一个错误结果 ct.js:58 Uncaught TypeError: Cannot
"content_scripts": [{
"js": [ "ct.js" ],
"matches": [ "<all_urls>" ]
}],
"permissions": [ "management","storage","proxy", "*://*/*" ],
我在控制台中得到一个错误结果
ct.js:58 Uncaught TypeError: Cannot read property 'onInstalled' of undefined
{
app: Object
csi: function()
loadTimes: function()
runtime: Object
webstore: Object
__proto__: Object
}
控制台中的I logchrome
变量
ct.js:58 Uncaught TypeError: Cannot read property 'onInstalled' of undefined
{
app: Object
csi: function()
loadTimes: function()
runtime: Object
webstore: Object
__proto__: Object
}
我两天前就被卡住了。任何对我的帮助都是对我生命的巨大帮助
对不起,我的英语不好。感谢收看。您不能使用
chrome.management.*
API(或者,就此而言,chrome.runtime.onInstalled
事件);这是一个不那么特权的环境
但是,内容脚本有一些限制。他们不能:
- 使用chrome.*API,但以下情况除外:
- 扩展名(getURL、inIncognitoContext、lastError、onRequest、sendRequest)
- i18n
- 运行时(connect、getManifest、getURL、id、onConnect、onMessage、sendMessage)
- 储藏
您需要有一个或脚本来为您处理它。如果您需要对其做出反应,或者从内容脚本启动某些内容,那么背景就是答案。您不能使用
chrome.management.*
API(或者,就此而言,chrome.runtime.onInstalled
事件);这是一个不那么特权的环境
但是,内容脚本有一些限制。他们不能:
- 使用chrome.*API,但以下情况除外:
- 扩展名(getURL、inIncognitoContext、lastError、onRequest、sendRequest)
- i18n
- 运行时(connect、getManifest、getURL、id、onConnect、onMessage、sendMessage)
- 储藏