无法将内容脚本注入我的Chrome扩展程序的所有IFRAME中

c00*_*0fd 2 javascript iframe google-chrome google-chrome-extension content-script

在我的Google Chrome扩展程序中,我需要能够将我的内容脚本注入IFRAME页面上的所有内容.要做到这一点,我的原件manifest.json被声明为:

"content_scripts": [
    {
        "run_at": "document_end",
        "all_frames" : true,
        "matches": ["http://*/*", "https://*/*"],
        "js": ["content.js"]
    }
],
Run Code Online (Sandbox Code Playgroud)

这似乎适用于大多数网站,直到我遇到一个IFRAME声明如此:

(来自Chrome调试器) 在此输入图像描述

这是它的HTML:

<iframe id="wysiwygtext_ifr" src='javascript:""' frameborder="0" allowtransparency="true" title="Rich Text Area." style="width: 100%; height: 341px; display: block;"></iframe>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我的内容脚本不会注入其中IFRAME.

我尝试更改matches过滤器,"matches": ["<all_urls>"]但仍然没有这样做.

有没有办法为我注入我的内容脚本中的IFRAME那样?

Sco*_*ott 6

这正是match_about_blank为其创建标志的问题.它最终在Chrome 37中稳定发布.

只需添加"match_about_blank": true内容脚本定义即可.

您也可以在tabs.executeScript中使用它.看到: