Javascript 内容脚本不是';t在另一个扩展内的iframe中运行';s页

Javascript 内容脚本不是';t在另一个扩展内的iframe中运行';s页,javascript,iframe,google-chrome-extension,Javascript,Iframe,Google Chrome Extension,假设Google Chrome中安装了2个扩展 第一个扩展在w3.org上运行content.js: manifest.json: "content_scripts": [{ "matches": [ "https://www.w3.org/*" ], "all_frames": true, "js": [ "content.js" ] }] "web_accessible_resources": ["page.html"] content.js: alert('c

假设Google Chrome中安装了2个扩展


第一个扩展在w3.org上运行content.js:

manifest.json:

"content_scripts": [{
    "matches": [ "https://www.w3.org/*" ],
    "all_frames": true,
    "js": [ "content.js" ]
}]
"web_accessible_resources": ["page.html"]
content.js:

alert('content');

第二个扩展名有page.html,它将w3.org加载到iframe中:

manifest.json:

"content_scripts": [{
    "matches": [ "https://www.w3.org/*" ],
    "all_frames": true,
    "js": [ "content.js" ]
}]
"web_accessible_resources": ["page.html"]
page.html:

<!DOCTYPE html>
<iframe src="https://www.w3.org/"></iframe>


现在输入地址栏
chrome-extension://2nd-extension-id/page.html
。您将看到w3.com,但content.js没有运行(没有
alert()
window)。我在控制台中没有看到错误

问题是:如何允许内容脚本在此iframe中运行



我创建了。状态:不幸的是,WontFix。但这是可以在将来改变的…

你不能使用扩展,但你可以在谷歌应用程序中做类似的事情:
可以使用而不是iframe。因此,您可以通过
executeScript
方法注入脚本。

您根本不能。扩展无法在其他扩展中运行。允许这样的事情会让恶意的扩展做一些非常糟糕的事情。@Marc Guiselin,no.w3.org不是扩展的一部分,并且在自己的上下文中以标准权限运行。但是,
仅适用于Chrome应用程序,而不适用于扩展。