gpt4 book ai didi

javascript - 无法从我的 Chrome 扩展程序将内容脚本注入(inject)所有 IFRAME

转载 作者:行者123 更新时间:2023-11-29 16:11:45 30 4
gpt4 key购买 nike

在我的 Google Chrome 扩展程序中,我需要能够将我的内容脚本 注入(inject)所有 IFRAME在页面上。为此,我的原创 manifest.json声明如下:

"content_scripts": [
{
"run_at": "document_end",
"all_frames" : true,
"matches": ["http://*/*", "https://*/*"],
"js": ["content.js"]
}
],

这似乎适用于大多数网站,直到我遇到 IFRAME是这样声明的:

(来自 Chrome 调试器) enter image description here

这是它的 HTML:

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

在这种情况下,我的内容脚本没有被注入(inject)到 IFRAME 中.

我尝试更改 matches过滤到 "matches": ["<all_urls>"]但还是不行。

有什么方法可以让我在 IFRAME 中注入(inject)我的内容脚本像那样?

最佳答案

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

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

您也可以在 tabs.executeScript 中使用它。见:

关于javascript - 无法从我的 Chrome 扩展程序将内容脚本注入(inject)所有 IFRAME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25756415/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com