Google chrome Chrome扩展内容脚本没有注入到大多数页面中
我正在尝试构建一个基本扩展,在加载的每个页面中注入一个警报脚本。但是脚本似乎只注入了一些页面(大多数页面没有注入),我找不到它如何选择要注入的页面的模式 这是舱单:Google chrome Chrome扩展内容脚本没有注入到大多数页面中,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我正在尝试构建一个基本扩展,在加载的每个页面中注入一个警报脚本。但是脚本似乎只注入了一些页面(大多数页面没有注入),我找不到它如何选择要注入的页面的模式 这是舱单: { "name": "TestingTest", "version": "0.1.1", "description": "Testing Tests!", "manifest_version": 2, "content_scripts": [
{
"name": "TestingTest",
"version": "0.1.1",
"description": "Testing Tests!",
"manifest_version": 2,
"content_scripts": [
{
"matches": ["http://*/", "https://*/"],
"js": ["content.js"],
"run_at": "document_end"
}
],
"background": {
"page": "background.html"
},
"permissions": [
"tabs",
"http://*/", "https://*/",
"cookies"
],
"icons": {
"16": "my_icon_64.png",
"32": "my_icon_64.png",
"48": "my_icon_64.png",
"128": "my_icon_64.png"
}
}
这是ccontent.js
:
alert("content script");
console.log("content script")
我只在一些特定的页面上收到警报。如果我在不同的Chrome配置文件中加载扩展名,它插入的页面似乎会有所不同。您的内容脚本可能只在路径名为
/
的页面上加载。在url模式的末尾添加一个额外的*
:
"matches": ["http://*/*", "https://*/*"]
感谢您编写了一个很好的问题,其中包含了足够的代码片段,供潜在的回答者快速查看问题。