1
我已经创建了一个Chrome扩展,其中包含两个html页面background.html
和helper.html
。如何将内容脚本注入扩展中运行的html页面内
我正在尝试将代码注入helper.html
,该代码在扩展内部运行。 helper.html
作为我使用chrome创建的popup
窗口运行。 windows.create(object createData, function callback)
。但是,到目前为止,我无法这样做。从文档我明白,我的内容脚本规则应该是
"content_scripts": [
{
"matches": ["chrome-extension://*/*"],
"js": ["jquery.js","myscript.js"],
"css": ["style.css"],
"run_at": "document_end"
}
但它失败。
需要注意的是,当我使用localhost代替,例如
"content_scripts": [
{
"matches": ["http://localhost/"],
"js": ["jquery.js","myscript.js"],
"css": ["style.css"],
"run_at": "document_end"
}
它的工作原理。本地主机运行完全相同的代码,但不知怎的,扩展拒绝识别我想匹配的文件("matches": ["chrome-extension://*/*"]
)