Use browser actions to put icons in the main browser toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.

Manifest keys: action, browser_action

Needs at least manifest version 3.

Not allowed in: Content scripts, Devtools pages

_GetUserSettingsReturnUserSettings
_OpenPopupOptions
_SetBadgeBackgroundColorDetails
_SetBadgeTextColorDetails
_SetBadgeTextDetails
_SetIconDetails
_SetPopupDetails
_SetTitleDetails
Details
OnClickData
_OnClickDataModifiers
ColorArray
ColorValue
ImageDataType
onClicked
disable
enable
getBadgeBackgroundColor
getBadgeText
getBadgeTextColor
getPopup
getTitle
getUserSettings
isEnabled
openPopup
setBadgeBackgroundColor
setBadgeText
setBadgeTextColor
setIcon
setPopup
setTitle
_OnClickDataModifiers: "Shift" | "Alt" | "Command" | "Ctrl" | "MacCtrl"
ColorArray: [number, number, number, number]
ColorValue: string | browser.action.ColorArray | null

An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is [255, 0, 0, 255]. Can also be a string with a CSS value, with opaque red being #FF0000 or #F00.

ImageDataType: ImageData

Pixel data for an image. Must be an ImageData object (for example, from a canvas element).

onClicked: WebExtEvent<(tab: Tab, info?: browser.action.OnClickData) => void>

Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.

  • Disables the browser action for a tab.

    Parameters

    • OptionaltabId: number

      The id of the tab for which you want to modify the browser action.

    Returns Promise<void>

  • Enables the browser action for a tab. By default, browser actions are enabled.

    Parameters

    • OptionaltabId: number

      The id of the tab for which you want to modify the browser action.

    Returns Promise<void>

  • Gets the badge text of the browser action. If no tab nor window is specified is specified, the global badge text is returned.

    Parameters

    Returns Promise<string>

  • Gets the text color of the browser action badge.

    Parameters

    Returns Promise<any>

  • Gets the html document set as the popup for this browser action.

    Parameters

    Returns Promise<string>

  • Gets the title of the browser action.

    Parameters

    Returns Promise<string>

  • Checks whether the browser action is enabled.

    Parameters

    Returns Promise<any>

  • Opens the extension popup window in the specified window.

    Parameters

    Returns Promise<boolean>

  • Sets the background color for the badge.

    Parameters

    • details: browser.action._SetBadgeBackgroundColorDetails

      Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.

    Returns Promise<void>

  • Sets the badge text for the browser action. The badge is displayed on top of the icon.

    Parameters

    • details: browser.action._SetBadgeTextDetails

      Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.

    Returns Promise<void>

  • Sets the text color for the badge.

    Parameters

    • details: browser.action._SetBadgeTextColorDetails

      Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.

    Returns Promise<any>

  • Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified.

    Parameters

    • details: browser.action._SetIconDetails

      Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.

    Returns Promise<void>

  • Sets the html document to be opened as a popup when the user clicks on the browser action's icon.

    Parameters

    • details: browser.action._SetPopupDetails

      Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.

    Returns Promise<void>

  • Sets the title of the browser action. This shows up in the tooltip.

    Parameters

    • details: browser.action._SetTitleDetails

      Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.

    Returns Promise<void>