management.setEnabled()

Enables or disables the given add-on.

This function must usually be called in the context of a user action, such as the click handler for a button. The browser may also ask the user to confirm the change.

This API requires the "management" API permission.

It is an asynchronous function that returns a Promise.

Syntax

var settingEnabled = browser.management.setEnabled(
  id,              // string
  enabled         // boolean
)

Parameters

id
string. ID of the add-on to enable/disable.
enabled
boolean. Whether to enable or disable the add-on.

Return value

A Promise that will be fulfilled with no arguments when the add-on has been disabled or enabled.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
Basic supportChrome Full support YesEdge No support NoFirefox Full support 55
Notes
Full support 55
Notes
Notes Only extensions whose 'type' is 'theme' can be enabled and disabled.
Opera Full support YesFirefox Android Full support 55
Notes
Full support 55
Notes
Notes Only extensions whose 'type' is 'theme' can be enabled and disabled.

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

Examples

Toggle enable/disable for the add-on whose ID is "my-add-on":

var id = "my-add-on";

function toggleEnabled(id) {
  var getting = browser.management.get(id);
  getting.then((info) => {
    browser.management.setEnabled(id, !info.enabled);
  });
}

toggleEnabled(id);

Example extensions

Acknowledgements

This API is based on Chromium's chrome.management API. This documentation is derived from management.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

Contributors to this page: wbamberg, andrewtruongmoz, ericjung
Last updated by: wbamberg,