action.isEnabled()

Returns true if the browser action is enabled.

Note: This API is available in Manifest V3 or higher.

Syntax

js
let gettingIsEnabled = browser.action.isEnabled(
  details // object
)

Parameters

details Optional

object. An object optionally containing the tabId or windowId to check.

tabId Optional

integer. ID of a tab to check.

windowId Optional

integer. ID of a window to check.

  • If windowId and tabId are supplied, the function fails.
  • If details, or windowId and tabId are omitted, the global status is returned.

Note: Chrome doesn't support the details object. It provides for setting an optional tabId only.

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.action.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.action.isEnabled({
    tabId: tabs[0].id,
  });
  console.log(enabled);
}

Browser compatibility