在基于 WebExtensions 的浏览器 add-on 中更改浏览器的 window 标题
Change the browser's window title in a WebExtensions based browser add-on
WebExtensions API 是否允许更改浏览器的 window 标题?
例如。更改“WebExtensions - Stack Overflow - Mozilla Firefox”
到“浏览器 - Window 1”
或“浏览器 - Window 1 - WebExtensions - Stack Overflow”
旧的 XUL 扩展中的 Firefox 是可能的(请参阅 FireTitle 扩展。)
可能,在某种程度上,在桌面 Firefox 56 和更新版本中
在 Firefox 56 中,Mozilla 添加了 titlePreface
property to what can be passed in the updateInfo
parameter in calls to windows.update()
。
MDN's documentation for the titlePreface
property 说:
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).
示例:
要将前缀 "Current Window: " 添加到当前 window 的标题,您可以执行以下操作:
browser.windows.getCurrent()
.then(winInfo => browser.windows.update(winInfo.id, {titlePreface:'Current Window: '}));
在 Google Chrome、Firefox for Android、56 版之前的 Firefox Desktop 或其他浏览器中不可用
Browser Compatibility section for windows.update()
表示此功能可用的唯一浏览器是 Desktop Firefox 版本 56+,因此在其他使用 WebExtensions 的浏览器中是不可能的。
Mozilla 错误 1333376 - Feature request: a WebExtension API to change the window title
RESOLVED FIXED in Firefox 56
来自 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. …
WebExtensions API 是否允许更改浏览器的 window 标题?
例如。更改“WebExtensions - Stack Overflow - Mozilla Firefox” 到“浏览器 - Window 1” 或“浏览器 - Window 1 - WebExtensions - Stack Overflow”
旧的 XUL 扩展中的 Firefox 是可能的(请参阅 FireTitle 扩展。)
可能,在某种程度上,在桌面 Firefox 56 和更新版本中
在 Firefox 56 中,Mozilla 添加了 titlePreface
property to what can be passed in the updateInfo
parameter in calls to windows.update()
。
MDN's documentation for the titlePreface
property 说:
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).
示例:
要将前缀 "Current Window: " 添加到当前 window 的标题,您可以执行以下操作:
browser.windows.getCurrent()
.then(winInfo => browser.windows.update(winInfo.id, {titlePreface:'Current Window: '}));
在 Google Chrome、Firefox for Android、56 版之前的 Firefox Desktop 或其他浏览器中不可用
Browser Compatibility section for windows.update()
表示此功能可用的唯一浏览器是 Desktop Firefox 版本 56+,因此在其他使用 WebExtensions 的浏览器中是不可能的。
Mozilla 错误 1333376 - Feature request: a WebExtension API to change the window title
RESOLVED FIXED in Firefox 56
来自 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. …