I am creating a firefox extension. It is working fine. But the problem is that when I add button to my navigation toolbar, it removes/disables other buttons on the toolbar. Kindly please check what is wrong with my code below:
id = "my-toolbar-button";
if (!document.getElementById(id))
{
var navbar = document.getElementById("nav-bar");
var newset = navbar.currentSet + ",my-toolbar-button";
navbar.currentSet = newset;
navbar.setAttribute("currentset", newset );
document.persist("nav-bar", "currentset");
}
I have found the anwser in the following post: Automatically install toolbarbutton to firefox nav-bar, not working with insertItem
The above code runs even before firefox has initialized the toolbar. So It adds its button to the default toolbar and sets it. The solution is to wait for firefox to initialize by using an evenlistener on load. like this: