WebExtensions API 是否允许更改浏览器的窗口标题?
例如。更改“WebExtensions - 堆栈溢出 - Mozilla Firefox”
到“浏览器 - 窗口 1”
或“浏览器 - 窗口 1 - WebExtensions - 堆栈内存溢出”
旧 XUL 扩展中的 Firefox 是可能的(请参阅 FireTitle 扩展。)
最佳答案
在一定程度上可以在 Desktop Firefox 56 和更新版本中使用
在 Firefox 56 中,Mozilla 添加了 titlePreface
property到 updateInfo
中可以传递的内容调用 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).
例子:
要将前缀“当前窗口:”添加到当前窗口的标题,您可以执行以下操作:
browser.windows.getCurrent()
.then(winInfo => browser.windows.update(winInfo.id, {titlePreface:'Current Window: '}));
在 Google Chrome、Firefox for Android、Firefox Desktop 56 之前的版本或其他浏览器中无法使用
Browser Compatibility section for
windows.update()
表示唯一可用此功能的浏览器是 Desktop Firefox 版本 56+,因此在其他使用 WebExtensions 的浏览器中是不可能的。
关于javascript - 在基于 WebExtensions 的浏览器插件中更改浏览器的窗口标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40801920/