browserAction¶
The browserAction and composeAction APIs first appeared in Thunderbird 64. They are very similar to Firefox’s browserAction API.
Many of our sample extensions use a browserAction.
Use a browserAction to put an icon in the mail window toolbar. In addition to its icon, a browserAction can also have a tooltip, a badge, and a popup. This namespace is called browserAction for compatibility with browser WebExtensions.
Manifest file properties¶
browser_action]browser_style]default_area]default_label]default_popup]default_title]Functions¶
setTitle(details)¶
Sets the title of the browserAction. This shows up in the tooltip and the label. Defaults to the add-on name.
detailstitlegetTitle(details)¶
setLabel(details)¶
Sets the label of the browserAction, defaults to its title. Can be set to an empty string to not display any label. If the containing toolbar is configured to display text only, the title will be used as fallback.
detailslabelgetLabel(details)¶
setIcon(details)¶
Sets the icon for the browserAction. 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.
detailssetPopup(details)¶
Sets the html document to be opened as a popup when the user clicks on the browserAction’s icon.
detailspopupgetPopup(details)¶
Gets the html document set as the popup for this browserAction.
setBadgeText(details)¶
Sets the badge text for the browserAction. The badge is displayed on top of the icon.
detailstextgetBadgeText(details)¶
Gets the badge text of the browserAction. If no tab nor window is specified, the global badge text is returned.
setBadgeBackgroundColor(details)¶
Sets the background color for the badge.
details[255, 0, 0, 255]. Can also be a string with a CSS value, with opaque red being #FF0000 or #F00.getBadgeBackgroundColor(details)¶
enable([tabId])¶
Enables the browserAction for a tab. By default, a browserAction is enabled.
tabId]disable([tabId])¶
Disables the browserAction for a tab.
tabId]isEnabled(details)¶
openPopup()¶
Opens the extension popup window in the active window.
Events¶
onClicked(tab, [info])¶
Fired when a browserAction icon is clicked. This event will not fire if the browserAction has a popup. This is a user input event handler. For asynchronous listeners some restrictions apply.
Types¶
ColorArray¶
An array of four integers in the range [0,255] that make up the RGBA color. For example, opaque red is [255, 0, 0, 255].
Details¶
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.
tabId]windowId]ImageDataDictionary¶
A {size: ImageDataType} dictionary representing the icon to be set. The actual ImageDataType to be used is chosen depending on the screen’s pixel density. See the MDN documentation on browser styles for more information on this. At least one ImageDataType must be specified.
ImageDataType¶
Pixel data for an image. Must be an ImageData object (for example, from a canvas element).
OnClickData¶
Information sent when a browser action is clicked.
modifiersAn array of keyboard modifiers that were held while the menu item was clicked.
Supported values:
ShiftAltCommandCtrlMacCtrldom.event.treat_ctrl_click_as_right_click.disabled preference is not enabled and the MacCtrl modifier key is not forwarded to the API.button]External Types¶
The following types are not defined by this API, but by the underlying Mozilla WebExtension code base. They are included here, because there is no other public documentation available.
IconPathDictionary¶
A {size: path} dictionary representing the icon to be set. The actual image to be used is chosen depending on the screen’s pixel density. See the MDN documentation about choosing icon sizes for more information on this. At least one icon must be specified. Example:
{
"48": "icon48.png",
"96": "icon96.png"
}
ThemeIcons¶
Define a set of icons for themes depending on whether Thunderbird detects that the theme uses dark or light text. All provided URLs must be relative to the manifest.json file.
darkdefault_icon is specified).lightsize16 or 32.