Opening a specific url when a Firefox addon has been installed

痴心易碎 提交于 2019-12-11 06:21:11

问题


I am using the Firefox SDK to create an add-on. I would like a specific webpage to be open once that add-on is successfully installed. I created a module to attempt to do so:

var tabs = require("sdk/tabs");

exports.main = function (options, callbacks) {
    if (options.loadReason === 'install') {
        tabs.open("https://www.google.com");
    }
};

exports.onUnload = function (reason) {
  if (reason === 'uninstall') {
      tabs.open("https://www.google.com");
  }
};

I then require this script in my main.js file (handlers.js is the name of the above script):

require("handlers.js");

However, this script does not execute -- whether during installation or uninstallation. I have tried the following links for help, but I don't seem to be able to solve my issue:

https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Listening_for_load_and_unload

Opening a page after Firefox extension install


回答1:


The solution for this was repackaging the add-on with the package.json and it worked except for the onUnload function which has a bug and uninstall is never called as a reason and as such I had to use "disable" as the reason to check for and it worked!.

For more on the bug refer to: https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Listening_for_load_and_unload



来源:https://stackoverflow.com/questions/31436624/opening-a-specific-url-when-a-firefox-addon-has-been-installed

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