Documentation: Chrome Action API
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.
- disableAction(tabId)
- enableAction(tabId)
- getBadgeBgColor(tabId?)
- getBadgeText(tabId?)
- getBadgeTextColor(tabId?) [MV3]
- getActionPopup(tabId?)
- getActionTitle(tabId?)
- getActionUserSetting() [MV3]
- isActionEnabled(tabId)
- openActionPopup(windowId?) [MV3]
- setBadgeBgColor(color, tabId?)
- setBadgeText(text, tabId?)
- setBadgeTextColor(color, tabId?) [MV3]
- setActionIcon(details)
- setActionPopup(popup, tabId?)
- setActionTitle(title, tabId?)
- getDefaultPopup()
- clearBadgeText(tabId?)
disableAction(tabId: number): Promise<void>
Disables the extension action for the specified tab. Falls back to chrome.browserAction.disable in MV2.
enableAction(tabId: number): Promise<void>
Enables the extension action for the specified tab. Falls back to chrome.browserAction.enable in MV2.
getBadgeBgColor(tabId?: number): Promise<[number, number, number, number]>
Retrieves the badge background color for a given tab.
getBadgeText(tabId?: number): Promise<string>
Retrieves the badge text for a given tab.
getBadgeTextColor(tabId?: number): Promise<[number, number, number, number]>
Retrieves the badge text color for a given tab (Manifest V3 only).
getActionPopup(tabId?: number): Promise<string>
Retrieves the popup URL set for the action in a given tab.
getActionTitle(tabId?: number): Promise<string>
Retrieves the title set for the action in a given tab.
getActionUserSetting(): Promise<chrome.action.UserSettings>
Retrieves the user settings for the action (Manifest V3 only).
isActionEnabled(tabId: number): Promise<boolean>
Checks whether the action is enabled for the specified tab.
openActionPopup(windowId?: number): Promise<void>
Programmatically opens the action popup (Manifest V3 only).
setBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise<void>
Sets the badge background color for a given tab.
setBadgeText(text: string | number, tabId?: number): Promise<void>
Sets the badge text for a given tab.
setBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise<void>
Sets the badge text color for a given tab (Manifest V3 only).
setActionIcon(details: chrome.action.TabIconDetails): Promise<void>
Sets the action icon for a tab or globally.
setActionPopup(popup: string, tabId?: number): Promise<void>
Sets the popup URL for the action in a given tab.
setActionTitle(title: string, tabId?: number): Promise<void>
Sets the title for the action in a given tab.
getDefaultPopup(): string
Returns the default popup URL from the manifest (action.default_popup in MV3 or browser_action.default_popup in MV2).
clearBadgeText(tabId?: number): Promise<void>
Clears the badge text for a given tab.
onActionClicked(callback: (tab: chrome.tabs.Tab) => void): () => void
Adds a listener for the action clicked event. Returns an unsubscribe function.
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.