How to run on browser start

徘徊边缘 提交于 2019-12-11 12:59:08

问题


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.


回答1:


I found the answer here.

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


来源:https://stackoverflow.com/questions/35555039/how-to-run-on-browser-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!