Skip to content

Instantly share code, notes, and snippets.

@JangoSteve
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JangoSteve/088f1fd13aa4d1247d3a to your computer and use it in GitHub Desktop.
Save JangoSteve/088f1fd13aa4d1247d3a to your computer and use it in GitHub Desktop.
Programmatically uninstall an old version of an extension with a different UUID (i.e. loading new version with changed UUID would install side-by-side)
const {Cu} = require("chrome");
Cu.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAllAddons(function(aAddons) {
// Here aAddons is an array of Addon objects
var len = aAddons.length;
console.log("Addons!");
for (var i = 0; i < len; i++) {
var addon = aAddons[i];
console.log(addon.id, addon.name, addon.version, addon.isActive, addon.userDisabled);
if (addon.name == "MyAddonName") {
var version = addon.version.split(/\./);
if (version[0] == "0" && (version[1] < "3" || (version[1] == "3" && version[2] < "4"))) {
console.log("Old version! Uninstalling...", addon.version, version);
addon.uninstall();
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment