Programmatically enable/disable an extension

Talk about add-ons and extension development.
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted January 29th, 2017, 5:52 pm


The following code toggles (enables/disables) an extension:

Code: Select all

AddonManager.getAddonByID("", function(addon) {
     if (!addon) {
      alert("Not found!");
  addon.userDisabled = !addon.userDisabled;

I'm trying to enable/disable Roboform.
This is its install.rdf:

Code: Select all
<?xml version="1.0"?>
<RDF xmlns="" xmlns:em="">
  <Description about="urn:mozilla:install-manifest">
    <em:name>RoboForm Toolbar</em:name>
    <em:description>RoboForm is password manager and form filler for Firefox.</em:description>
    <em:creator>Siber Systems Inc.</em:creator>

    <!-- Firefox -->

I understand I should use "AddonManager.getAddonBySyncGUID()".
The following code does not work ("Not found!").

Code: Select all

AddonManager.getAddonBySyncGUID("22119944-ED35-4ab1-910B-E619EA06A115", function(addon) {
  if (!addon) {
    alert("Not found!");
  addon.userDisabled = !addon.userDisabled;

I'd appreciate your help.

Posts: 2600
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 30th, 2017, 4:33 am

The id and syncGUID strings are not the same. The syncGUID string is not shown in the install.rdf file.

Code: Select all
// Greasemonkey
alert(; // {e4a8a97b-f2ed-450b-b12d-ee082ba24781}
alert(addon.syncGUID); // {c91c4126-4022-4a9e-b9f2-07f9feb10e18}

Greasemonkey ... asemonkey/

Greasemonkey install.rdf ... nstall.rdf

You can check the id and syncGUID strings with scratchpad in browser environment.


* open about:config
* set to true
* tools > web developer > scratchpad
* environment > browser
* edit > paste (i.e. copy and paste code snippet)
* execute > run

Code: Select all
AddonManager.getAddonsByTypes(["extension"], function (addons) {
  var list = [];
  addons.forEach(function (addon) {
    if (addon.hidden == false) {
      list.push( + ", id: " + +
        ", syncGUID: " + addon.syncGUID);


And do not forget the braces in the id and syncGUID strings.

Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted January 30th, 2017, 8:57 pm

Hello morat,

Thank you for the detailed and helpful reply. I appreciate it.

Well, before posting here I tried "AddonManager.getAddonByID" with the ID in install.rdf.
It would work with an extension having the "" ID type but not with an extension having the "{e4a8a97b-f2ed-450b-b12d-ee082ba24781}" ID type.
I then tried "AddonManager.getAddonBySyncGUID" (with and without the braces) which as you've explained shouldn't work with the ID in install.rdf.

I suppose I only tried "AddonManager.getAddonByID" *without* the braces.
Using it now *with* the braces, it works perfectly.

Sorry for the late reply. I've had a busy day.

Best regards.

Return to Extension Development

Who is online

Users browsing this forum: No registered users and 3 guests