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
.
The function allows enabling/disabling of theme addons, but will return an error if used to enable or disable other types of web extension.
Syntax
let settingEnabled = browser.management.setEnabled(
id,
enabled
)
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
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
setEnabled |
Yes |
79 |
55Only extensions whose 'type' is 'theme' can be enabled and disabled.
|
? |
Yes |
No |
? |
? |
55Only extensions whose 'type' is 'theme' can be enabled and disabled.
|
? |
No |
? |
Examples
Toggle enable/disable for the add-on whose ID is "my-add-on":
let id = "my-add-on";
function toggleEnabled(id) {
let getting = browser.management.get(id);
getting.then((info) => {
browser.management.setEnabled(id, !info.enabled);
});
}
toggleEnabled(id);