I've developed an add-on for Firefox and is installs ok in windows Firefox but in linux mint i must go to the View menu then toolbars and select personalize to put the created add-on button to the toolbar near my firebug (i mean where other add-ons coexist)
1
votes
1 Answers
1
votes
To put a toolbarbutton on the nav-bar automatically, it isn't enough to create the button. You have to add it to the "current set" of icons in the toolbar. If you don't do this, it will only be added to the
My guess is your code is not working on windows either. You may have added it to the toolbar manually some time ago and it is there since.(Try installing your addon in a blank profile).
To make it "persistent" automatically you can add it to the current set on the first time you run your addon, with the following:
/**
* 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");
}
Reference: Toolbar - Code snippets