Skip to content

Latest commit

 

History

History
233 lines (146 loc) · 5.01 KB

File metadata and controls

233 lines (146 loc) · 5.01 KB

action

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.

Methods

Events


disableAction

disableAction(tabId: number): Promise<void>

Disables the extension action for the specified tab. Falls back to chrome.browserAction.disable in MV2.

enableAction

enableAction(tabId: number): Promise<void>

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<string>

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<string>

Retrieves the popup URL set for the action in a given tab.

getActionTitle

getActionTitle(tabId?: number): Promise<string>

Retrieves the title set for the action in a given tab.

getActionUserSetting [MV3]

getActionUserSetting(): Promise<chrome.action.UserSettings>

Retrieves the user settings for the action (Manifest V3 only).

isActionEnabled

isActionEnabled(tabId: number): Promise<boolean>

Checks whether the action is enabled for the specified tab.

openActionPopup [MV3]

openActionPopup(windowId?: number): Promise<void>

Programmatically opens the action popup (Manifest V3 only).

setBadgeBgColor

setBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise<void>

Sets the badge background color for a given tab.

setBadgeText

setBadgeText(text: string | number, tabId?: number): Promise<void>

Sets the badge text for a given tab.

setBadgeTextColor [MV3]

setBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise<void>

Sets the badge text color for a given tab (Manifest V3 only).

setActionIcon

setActionIcon(details: chrome.action.TabIconDetails): Promise<void>

Sets the action icon for a tab or globally.

setActionPopup

setActionPopup(popup: string, tabId?: number): Promise<void>

Sets the popup URL for the action in a given tab.

setActionTitle

setActionTitle(title: string, tabId?: number): Promise<void>

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<void>

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.