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.
Mozilla bug 1333376 - Feature request: a WebExtension API to change the window title
RESOLVED FIXED in Firefox 56
From WebExtensions in Firefox 56 | Mozilla Add-ons Blog (2017-08-10):
… The
windows
API now has the ability to read and preface the title of the window object, by passing titlePreface to the window object. This allows extensions to label different windows so they’re easier to distinguish. …
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With