browserAction.getBadgeText()

Gets the browser action's badge text.

This is an asynchronous function that returns a Promise.

Syntax

js
let gettingText = browser.browserAction.getBadgeText(
  details               // object
)

Parameters

details

An object with the following properties:

tabId Optional

integer. Specifies the tab from which to get the badge text.

windowId Optional

integer. Specifies the window from which to get the badge text.

  • If windowId and tabId are both supplied, the function fails.
  • If windowId and tabId are both omitted, the global badge text is returned.

Return value

A Promise that will be fulfilled with a string containing the badge text.

Examples

Log the badge text:

js
function gotBadgeText(text) {
  console.log(text);
}

let gettingBadgeText = browser.browserAction.getBadgeText({});
gettingBadgeText.then(gotBadgeText);

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getBadgeText
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
details.windowId parameter
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 62 (Release date: 2018-09-05)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18 (Release date: 2024-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18 (Release date: 2024-09-16)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

Note: This API is based on Chromium's chrome.browserAction API. This documentation is derived from browser_action.json in the Chromium code.