Firefox插件:将内容脚本注入iframe,src为;关于:空白“;
我们正在开发一个插件,希望将内容脚本注入到首页和所有框架中。然而,我们发现内容脚本不能被注入iframe,src为“about:blank”或“javascript:…” 有什么意见/建议吗 示例页面模块:Firefox插件:将内容脚本注入iframe,src为;关于:空白“;,firefox,firefox-addon,firefox-addon-sdk,Firefox,Firefox Addon,Firefox Addon Sdk,我们正在开发一个插件,希望将内容脚本注入到首页和所有框架中。然而,我们发现内容脚本不能被注入iframe,src为“about:blank”或“javascript:…” 有什么意见/建议吗 示例页面模块: require("sdk/page-mod").PageMod({ include:["*", "file://*"], contentScriptFile: [ "./content/content.js",
require("sdk/page-mod").PageMod({
include:["*", "file://*"],
contentScriptFile: [
"./content/content.js",
],
attachTo: ["existing","top", "frame"],...
试试这个:
require("sdk/page-mod").PageMod({
include:["*", "file://*", "about:blank", "javascript:*"],
contentScriptFile: [
"./content/content.js",
],
attachTo: [[b]"existing","top", "frame"[/b]],...
我想更新我的队友Wayland发现的一个有趣的事实: 有趣的是,如果我们按照以下方式构建iframe,它将起作用: 这就像我们通过调用“document.write”来刷新iframe内容一样
函数buildme(){
var-iframe=。。。;
iframe.contentDocument.open();
iframe.contentDocument.write(“”);
iframe.contentDocument.close()
var child=iframe.contentDocument.CraetElement(“…”);
...
iframe.contentDocument.body.appendChild(子级);
}
onload=“buildme();”/>
现在firefox的内容脚本中有一个选项match\u about\u blank
:
很抱歉延迟重播,但不幸的是,这在Firefox插件中不起作用。谢谢Walty,这是用于WebExtension的,它与Chrome扩展类似。没关系,附加SDK现在已经过时了,所以在新的Firefox版本中,我们可以很好地使用WebExtension。