This is the embellishment of the first answer.
If you have the difficulties described by dcolish in his comment on the top answer, add this to main.js:
var tim = require("timers"); intervalId = tim.setInterval(timerFn,2000); function timerFn() { var win = mediator.getMostRecentWindow('navigator:browser'); if (win) var document = win.document; else return; var isBtn = document.getElementById('myappbutton-id'); if (!isBtn) addToolbarButton(); }
This is rude, but it works.
EDIT: Much simpler and cleaner:
var windows = require("windows").browserWindows; windows.on('open', function(window) { addToolbarButton(); });
On my Mac, Firefox 15 automatically removes the icon when the window closes. Therefore window.on('close', ...) not required.
semiomant
source share