MeL*_*ght 3 google-chrome google-chrome-extension
我正在尝试构建一个基本扩展,为每个加载的页面注入一个警报脚本.但似乎脚本只注入某些页面(大多数页面没有注入),我找不到一个模式来选择如何选择要注入的页面.
这是显而易见的:
{
"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"
}
}
Run Code Online (Sandbox Code Playgroud)
这是ccontent.js
:
alert("content script");
console.log("content script")
Run Code Online (Sandbox Code Playgroud)
我只在几个页面上收到警报.如果我在不同的Chrome配置文件中加载扩展程序,它注入的页面似乎会有所不同.
您的内容脚本可能只在路径名所在的页面上加载/
.*
在网址模式的末尾添加额外内容:
"matches": ["http://*/*", "https://*/*"]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2006 次 |
最近记录: |