Last active
August 29, 2015 14:02
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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