Skip to content Skip to sidebar Skip to footer

Firefox Addon Ignore Iframes

I'm trying to build an addon for LinkedIn but the contentscript is outputted in every frame... My main.js: exports.main = function() { var pageMod = require('page-mod'); page

Solution 1:

UPDATE, the SDK's page-mod api now supports 'attachTo', so you can do this instead:

var data = require("sdk/self").data;
var page = require('sdk/page-mod');

page.PageMod({
     match:['*'],
     contentScriptOptions: {},
     contentScriptFile: [data.url('myScript.js')],
     attachTo: 'top',
     onAttach: function(worker) {
         //set up hooks or other background behavior
     },
});

See this more recent question for more info.

There are two approaches you could look into:

1. attach your content scripts using the tabs module. This works because the tabs module only deals with top-level documents. Here is a simple example:

https://builder.addons.mozilla.org/package/22176/latest/

2. do an initial load of a very small content script via page-mod, and then if thepage is something you really want to mod, inject scripts by sending them via port.emit messages. There is an example of this sort of scheme from the dotjs add-on:

https://github.com/rlr/dotjs-addon


Post a Comment for "Firefox Addon Ignore Iframes"