user5254856
user5254856

Reputation: 21

How to run on browser start

I'm new to Firefox addon development.
I have the following code:

var windows = require("sdk/windows").browserWindows;
windows.on("open", function() {
    // do stuff
});

But this only runs for windows created after the browser is started, not the first one.
How can I fix this?

I know I could just copy the code outside of the open event, but then it also runs when the addon is installed and I don't want that.

Upvotes: 1

Views: 61

Answers (1)

user5254856
user5254856

Reputation: 21

I found the answer here.

exports.main = function (options, callbacks) {
    if (options.loadReason == "startup") {
        // do stuff     
    }
};

Upvotes: 1

Related Questions