0

I am able to know when the user is uninstalling or disabling the add-on by using the following code.

exports.onUnload = function (reason) {
    if(reason==="disable"||reason==="uninstall"){
        //stuff here  
}};

I need to stop disabling/uninstallation of the add-on. My add-on is a security related add-on. When the user is trying to uninstall the add-on, I need to confirm with the user using master password authentication. If he enters the master password, then uninstall the add-on. If he fails to enter the master password, then add-on should continue working.

1 Answers1

0

I think there are ways to make an addon "a system addon" so that it doesn't show up for uninstallation. I'm not sure how to do that though we'll have to ask around. Please ask around and share if you find out.

With the above method, the only thing you can do is, on uninstall/disable, you can re-enable the addon with the addon manager. This is an example of how to use the addon magner to modify an addons properties -

Cu.import('resource://gre/modules/AddonManager.jsm');
AddonManager.getAddonByID('Profilist@jetpack', function(addon) {
  console.info('addon:', addon);
  console.info('addon.applyBackgroundUpdates:', addon.applyBackgroundUpdates);
  addon.applyBackgroundUpdates = 0; //off
  //addon.applyBackgroundUpdates = 1; //default
  //addon.applyBackgroundUpdates = 2; //on
});

There should be properties relating to the addon enabled status. Just revert those to true when they change.

The user can still uninstall your addon, but they have to be a bit tech savvy, they would just go to the extensions folder in the file system and delete the addon file. On browser restart it wont be there anymore.

Noitidart
  • 35,443
  • 37
  • 154
  • 323