Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstall/Remove Firefox Extension programmatically?

Is there a way to uninstall Firefox extension programmatically. If yes - Is it possible to execute this script from some other extension ?

like image 903
user3824134 Avatar asked Dec 06 '25 03:12

user3824134


1 Answers

  1. Get a reference to the add-on using AddonManager.getAddonByID
  2. Check that the add-on can be uninstalled (e.g. system-wide add-ons cannot be uninstalled by the user normally, but can be disabled), by checking the PERM_CAN_UNINSTALL flag.
  3. Call Addon.uninstall().

Example code (you might want to add proper error handling, and so on):

Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("some@id", function(addon) {
  if (!addon) {
    // Add-on not present
    return;
  }
  if (!(addon.permissions & AddonManager.PERM_CAN_UNINSTALL)) {
    // Add-on cannot be uninstalled
    return;
  }
  addon.uninstall();
  if (addon.pendingOperations & AddonManager.PENDING_UNINSTALL) {
    // Need to restart to finish the uninstall.
    // Might ask the user to do just that. Or not ask and just do.
    // Or just wait until the browser is restarted by the user.
  }
});
like image 150
nmaier Avatar answered Dec 09 '25 20:12

nmaier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!