browserAction.isEnabled()
Returns true if the browser action is enabled.
Syntax
js
let gettingIsEnabled = browser.browserAction.isEnabled(
details // object
)
Parameters
detailsOptional-
object. An object optionally containing thetabIdorwindowIdto check.tabIdOptional-
integer. ID of a tab to check. windowIdOptional-
integer. ID of a window to check.
- If
windowIdandtabIdare supplied, the function fails. - If
details, orwindowIdandtabIdare omitted, the global status is returned.
Return value
A Promise fulfilled with true if the extension's browser action is enabled, and false otherwise.
Examples
Check the global state:
js
browser.browserAction.isEnabled({}).then((result) => {
console.log(result);
});
Check the state of the active tab:
js
async function enabledInActiveTab() {
let tabs = await browser.tabs.query({
currentWindow: true,
active: true,
});
let enabled = await browser.browserAction.isEnabled({
tabId: tabs[0].id,
});
console.log(enabled);
}