Google chrome extension Firefox插件开发-tabs api-黑名单url模式从注入exstension代码(如在chrome中)
我正在使用addons sdk/tabs api在加载选项卡时将内容脚本注入选项卡,如下所示:Google chrome extension Firefox插件开发-tabs api-黑名单url模式从注入exstension代码(如在chrome中),google-chrome-extension,firefox-addon,firefox-addon-sdk,browser-addons,Google Chrome Extension,Firefox Addon,Firefox Addon Sdk,Browser Addons,我正在使用addons sdk/tabs api在加载选项卡时将内容脚本注入选项卡,如下所示: tabs.on(ready, function (tab) { var worker = tab.attach({ contentScriptWhen: 'end', contentScriptFile: myAwesomeArrayOfScripts }); ... if (tab.url.indexOf('about:') === 0) return; 有没有一种
tabs.on(ready, function (tab) {
var worker = tab.attach({
contentScriptWhen: 'end',
contentScriptFile: myAwesomeArrayOfScripts
});
...
if (tab.url.indexOf('about:') === 0) return;
有没有一种简单的方法可以防止附加域模式?
最重要的是,我需要阻止它在以下领域工作:比如firefox的新标签页
很明显,我可以用这样的代码控制执行:
tabs.on(ready, function (tab) {
var worker = tab.attach({
contentScriptWhen: 'end',
contentScriptFile: myAwesomeArrayOfScripts
});
...
if (tab.url.indexOf('about:') === 0) return;
但与chrome声明性清单相比,它的解决方案看起来非常不明确,您可以使用:
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*", "file://*/*" ],
有类似的吗?Firefox文档令人困惑。。。内容太多,过去的版本和文章太多。如果要声明内容脚本,请使用,而不是通过选项卡事件附加内容脚本。然后可以使用include
和exclude
键指定URL模式(exclude
是Firefox32中引入的)
使用Firefox的选项卡。附加类似于,只应用于强制执行内容脚本。如果要声明内容脚本,请使用,而不是通过选项卡事件附加内容脚本。然后可以使用include
和exclude
键指定URL模式(exclude
是Firefox32中引入的)
使用Firefox的选项卡。attach
类似于,它只应用于强制执行内容脚本。很抱歉,由于响应延迟批准,我已经离开此项目一段时间了。当使用page mod注入脚本时,我是否仍然可以像使用选项卡api一样使用port.emit和port.on?@paolo.caminiti Yes。使用onAttach
事件获取worker
,然后使用worker.port
与选项卡的内容脚本通信。例如,请参阅抱歉,由于响应的批准延迟,我已经离开此项目一段时间了。当使用page mod注入脚本时,我是否仍然可以像使用选项卡api一样使用port.emit和port.on?@paolo.caminiti Yes。使用onAttach
事件获取worker
,然后使用worker.port
与选项卡的内容脚本通信。有关示例,请参见