# action Documentation: [Chrome Action API](https://developer.chrome.com/docs/extensions/reference/action) A unified, promise-based wrapper around the Chrome Action API. It transparently uses `chrome.action` on Manifest V3 and falls back to `chrome.browserAction` on Manifest V2. ## Methods - [disableAction(tabId)](#disableAction) - [enableAction(tabId)](#enableAction) - [getBadgeBgColor(tabId?)](#getBadgeBgColor) - [getBadgeText(tabId?)](#getBadgeText) - [getBadgeTextColor(tabId?)](#getBadgeTextColor) [MV3] - [getActionPopup(tabId?)](#getActionPopup) - [getActionTitle(tabId?)](#getActionTitle) - [getActionUserSetting()](#getActionUserSetting) [MV3] - [isActionEnabled(tabId)](#isActionEnabled) - [openActionPopup(windowId?)](#openActionPopup) [MV3] - [setBadgeBgColor(color, tabId?)](#setBadgeBgColor) - [setBadgeText(text, tabId?)](#setBadgeText) - [setBadgeTextColor(color, tabId?)](#setBadgeTextColor) [MV3] - [setActionIcon(details)](#setActionIcon) - [setActionPopup(popup, tabId?)](#setActionPopup) - [setActionTitle(title, tabId?)](#setActionTitle) - [getDefaultPopup()](#getDefaultPopup) - [clearBadgeText(tabId?)](#clearBadgeText) ## Events - [onActionClicked(callback)](#onActionClicked) - [onActionUserSettingsChanged(callback)](#onActionUserSettingsChanged) [MV3] --- ### disableAction ``` disableAction(tabId: number): Promise ``` Disables the extension action for the specified tab. Falls back to `chrome.browserAction.disable` in MV2. ### enableAction ``` enableAction(tabId: number): Promise ``` Enables the extension action for the specified tab. Falls back to `chrome.browserAction.enable` in MV2. ### getBadgeBgColor ``` getBadgeBgColor(tabId?: number): Promise<[number, number, number, number]> ``` Retrieves the badge background color for a given tab. ### getBadgeText ``` getBadgeText(tabId?: number): Promise ``` Retrieves the badge text for a given tab. ### getBadgeTextColor [MV3] ``` getBadgeTextColor(tabId?: number): Promise<[number, number, number, number]> ``` Retrieves the badge text color for a given tab (Manifest V3 only). ### getActionPopup ``` getActionPopup(tabId?: number): Promise ``` Retrieves the popup URL set for the action in a given tab. ### getActionTitle ``` getActionTitle(tabId?: number): Promise ``` Retrieves the title set for the action in a given tab. ### getActionUserSetting [MV3] ``` getActionUserSetting(): Promise ``` Retrieves the user settings for the action (Manifest V3 only). ### isActionEnabled ``` isActionEnabled(tabId: number): Promise ``` Checks whether the action is enabled for the specified tab. ### openActionPopup [MV3] ``` openActionPopup(windowId?: number): Promise ``` Programmatically opens the action popup (Manifest V3 only). ### setBadgeBgColor ``` setBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise ``` Sets the badge background color for a given tab. ### setBadgeText ``` setBadgeText(text: string | number, tabId?: number): Promise ``` Sets the badge text for a given tab. ### setBadgeTextColor [MV3] ``` setBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise ``` Sets the badge text color for a given tab (Manifest V3 only). ### setActionIcon ``` setActionIcon(details: chrome.action.TabIconDetails): Promise ``` Sets the action icon for a tab or globally. ### setActionPopup ``` setActionPopup(popup: string, tabId?: number): Promise ``` Sets the popup URL for the action in a given tab. ### setActionTitle ``` setActionTitle(title: string, tabId?: number): Promise ``` Sets the title for the action in a given tab. ### getDefaultPopup ``` getDefaultPopup(): string ``` Returns the default popup URL from the manifest (`action.default_popup` in MV3 or `browser_action.default_popup` in MV2). ### clearBadgeText ``` clearBadgeText(tabId?: number): Promise ``` Clears the badge text for a given tab. ### onActionClicked ``` onActionClicked(callback: (tab: chrome.tabs.Tab) => void): () => void ``` Adds a listener for the action clicked event. Returns an unsubscribe function. ### onActionUserSettingsChanged [MV3] ``` onActionUserSettingsChanged(callback: (settings: chrome.action.UserSettings) => void): () => void ``` Adds a listener for user settings changes on the action (Manifest V3 only). Returns an unsubscribe function.