The following code toggles (enables/disables) an extension:
Code: Select all
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("uBlock0@raymondhill.net", function(addon) {
if (!addon) {
alert("Not found!");
return;
}
addon.userDisabled = !addon.userDisabled;
});
This is its install.rdf:
Code: Select all
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:type>2</em:type>
<em:id>{22119944-ED35-4ab1-910B-E619EA06A115}</em:id>
<em:name>RoboForm Toolbar</em:name>
<em:version>7.9.23.0</em:version>
<em:description>RoboForm is password manager and form filler for Firefox.</em:description>
<em:creator>Siber Systems Inc.</em:creator>
<em:homepageURL>http://www.roboform.com</em:homepageURL>
<em:targetPlatform>WINNT</em:targetPlatform>
<em:targetPlatform>Darwin</em:targetPlatform>
<em:unpack>true</em:unpack>
<em:bootstrap>true</em:bootstrap>
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0</em:minVersion>
<em:maxVersion>52.0</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
The following code does not work ("Not found!").
Code: Select all
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonBySyncGUID("22119944-ED35-4ab1-910B-E619EA06A115", function(addon) {
if (!addon) {
alert("Not found!");
return;
}
addon.userDisabled = !addon.userDisabled;
});