Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法使用任何Chrome API来监听事件_Javascript_Google Chrome Extension_Google Chrome Devtools - Fatal编程技术网

Javascript 无法使用任何Chrome API来监听事件

Javascript 无法使用任何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

当然,这个问题太疯狂了,但我找不到任何解决办法

我的代码的详细信息:

manifest.json

"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 log
chrome
变量

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)
    • 储藏
您需要有一个或脚本来为您处理它。如果您需要对其作出反应,或者从内容脚本中启动某些内容,那么背景就是答案