Add-ons

browserAction.isEnabled()

Returns true if the browser action is enabled.

Browser actions can be enabled and disabled for specific tabs, or globally. This function accepts a tabId as a parameter:

  • If you supply tabId, the function will check the given tab.
  • If you omit tabId, the function will check the global state.

This is an asynchronous function that returns a Promise.

Syntax

let gettingIsEnabled = browser.browserAction.isEnabled(
  details // object
)

Parameters

details
object. An object optionally containing the tabId to check.
tabId Optional
integer. ID of a tab to check. If this is omitted, the global enabled/disabled status of the browser action will be returned.

Return value

A Promise that will be fulfilled with true if the extension's browser action is enabled, and false otherwise.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic support No No59 No No

Examples

Check the global state:

browser.browserAction.isEnabled({}).then(result => {
  console.log(result);
});

  Check the state of the currently active tab:

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);
}

Document Tags and Contributors

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