Search code examples
javascriptfirefoxfirefox-addonfirefox-addon-sdk

Firefox add-on: domain declaration


I developed a simple javascript injection which works very well. Can anybody tell me how to define the domain on which I want my firefox add-on to work for?

E.g. this doesn't work for www.myexample.com in main.js:

const self = require("self"),
page_mod = require("page-mod");

exports.main = function() {
    page_mod.PageMod({
        include: "*myexample.com*",
        contentScriptWhen: "ready",
        contentScriptFile: self.data.url("inject.js")
    });
};

These lines also don't work:

include: "*.myexample.com/*",
include: "*.myexample.com*",

Solution

  • It's all in the documentation:

    include: "*.example.com",
    

    The match-pattern module recognizes when you intend to match the domain name only, no need to add wildcards after the domain name.