我确实用content_scripts中的以下代码测试了我的google chrome扩展:
function test()
{
alert("test");
}
document.addEventListener("DOMContentLoaded", test, false);清单:
{
"name": "Test",
"version": "1.0",
"manifest_version": 2,
"permissions": ["contextMenus", "tabs", "http://*/*", "https://*/*"],
"content_scripts": [{
"all_frames": true,
"js": [ "jquery-1.8.1.min.js","test.js"],
"matches": [ "http://*/*" ],
"run_at": "document_start"
}]
}所有网页都可以使用,比如facebook或microsoft.....页面加载后,将弹出一个警报框,除了我在Google.com中访问的"Google.com“=>,但没有警报框。我想知道为什么除了Google.com,几乎所有的页面都是可以的?那么,我需要在加载Google.com之后捕获哪个DOM事件?
谢谢
发布于 2012-10-24 16:03:33
谷歌总是在https中,你的脚本不会注入到任何https网站,因为你只针对http网站(在你的清单中你有:"matches": [ "http://*/*" ],)。
将清单更改为"matches": [ "http://*/*", "https://*/*" ],或"matches": [ "<all_urls>" ],。
https://stackoverflow.com/questions/13044829
复制相似问题