我已经为Firefox开发了一个附加组件,并且在Windows Firefox中安装正常但在linux中我必须转到View菜单然后工具栏并选择个性化以将创建的附加按钮放到我的firebug附近的工具栏上(我的意思是其他附加组件共存的地方)
答案 0 :(得分:1)
要自动在导航栏上放置工具栏按钮,仅创建按钮是不够的。您必须将其添加到工具栏中的“当前设置”图标。如果您不这样做,它只会被添加到
我的猜测是您的代码也无法在Windows上运行。您可能已经在前一段时间手动将其添加到工具栏中,并且它就在那里。(尝试在空白配置文件中安装您的插件)。
要自动将其设为“持久”,您可以在首次运行插件时将其添加到当前设置中,具体如下:
/**
* Installs the toolbar button with the given ID into the given
* toolbar, if it is not already present in the document.
*
* @param {string} toolbarId The ID of the toolbar to install to.
* @param {string} id The ID of the button to install.
* @param {string} afterId The ID of the element to insert after. @optional
*/
function installButton(toolbarId, id, afterId) {
if (!document.getElementById(id)) {
var toolbar = document.getElementById(toolbarId);
// If no afterId is given, then append the item to the toolbar
var before = null;
if (afterId) {
let elem = document.getElementById(afterId);
if (elem && elem.parentNode == toolbar)
before = elem.nextElementSibling;
}
toolbar.insertItem(id, before);
toolbar.setAttribute("currentset", toolbar.currentSet);
document.persist(toolbar.id, "currentset");
if (toolbarId == "addon-bar")
toolbar.collapsed = false;
}
}
if (firstRun) {
installButton("nav-bar", "my-extension-navbar-button");
// The "addon-bar" is available since Firefox 4
installButton("addon-bar", "my-extension-addon-bar-button");
}