Does the WebExtensions API allow one to change the browser's window title?
Eg. Change "WebExtensions - Stack Overflow - Mozilla Firefox" to "Browser - Window 1" or "Browser - Window 1 - WebExtensions - Stack Overflow"
It was possible for Firefox in old XUL extensions (see the FireTitle extension.)
In Firefox 56, Mozilla added the titlePreface
property to what can be passed in the updateInfo
parameter in calls to windows.update()
.
MDN's documentation for the titlePreface
property says:
string
Use this to add a string to the beginning of the browser window's title. Depending on the underlying operating system, this might not work on browser windows that don't have a title (such as about:blank in Firefox).
To add the prefix "Current Window: " to the current window's title, you could do the following:
browser.windows.getCurrent()
.then(winInfo => browser.windows.update(winInfo.id, {titlePreface:'Current Window: '}));
The Browser Compatibility section for windows.update()
indicates that the only browser in which this feature is available is Desktop Firefox version 56+, so it's not possible in other browsers using WebExtensions.