javascript - 在基于 WebExtensions 的浏览器插件中更改浏览器的窗口标题

标签 javascript firefox google-chrome-extension firefox-addon firefox-addon-webextensions

WebExtensions API 是否允许更改浏览器的窗口标题?

例如。更改“WebExtensions - 堆栈溢出 - Mozilla Firefox”
到“浏览器 - 窗口 1”
或“浏览器 - 窗口 1 - WebExtensions - 堆栈内存溢出”

旧 XUL 扩展中的 Firefox 是可能的(请参阅 FireTitle 扩展。)

最佳答案

在一定程度上可以在 Desktop Firefox 56 和更新版本中使用

在 Firefox 56 中,Mozilla 添加了 titlePreface propertyupdateInfo 中可以传递的内容调用 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/

相关文章:

javascript - 在 HTML 网页中,noscript 标签内的内容不会被具有脚本阻止扩展的浏览器呈现

javascript - 如何禁用 prettyPhoto?

javascript - 使用 javascript 使用已安装的搜索引擎执行搜索

javascript - "The stylesheet was not loaded because its MIME type, "文本/html "is not "文本/css"

javascript - 在 'document_start' 处运行的内容脚本会阻止网页上的 JS 脚本?

javascript - 以 chrome 扩展形式转换时,事件函数不会在控制台中打印

javascript - 添加 onClick 事件以在 D3.js 中的每个栏上方显示一个隐藏的 div(也许我还缺少重要的 css 代码?)

javascript - 在 ng-options 中显示最新添加的项目

css - 为什么 Firefox 会忽略我全局指定的字体?

javascript - 如何禁用 Chrome 扩展中包含的脚本?