Skip to content

Instantly share code, notes, and snippets.

@Sporif
Last active October 3, 2022 18:27
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Sporif/ad6e917d87787491538bac80d3c8918c to your computer and use it in GitHub Desktop.
Save Sporif/ad6e917d87787491538bac80d3c8918c to your computer and use it in GitHub Desktop.
Restart Button for Firefox. An updated version of https://github.com/Endor8/userChrome.js/tree/master/restartfirefoxbutton_movable. Middle click also empties the script cache.
(function() {
if (location != 'chrome://browser/content/browser.xul' && location != 'chrome://browser/content/browser.xhtml')
return;
try {
CustomizableUI.createWidget({
id: 'restart-button',
type: 'custom',
defaultArea: CustomizableUI.AREA_NAVBAR,
onBuild: function(aDocument) {
var toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
toolbaritem.onclick = event => onClick(event);
var props = {
id: 'restart-button',
class: 'toolbarbutton-1 chromeclass-toolbar-additional',
label: 'Restart',
tooltiptext: 'Restart (with middle click userChrome.js cache is emptied)',
style: 'list-style-image: url(chrome://browser/skin/sync.svg)'
};
for(var p in props)
toolbaritem.setAttribute(p, props[p]);
return toolbaritem;
}
});
} catch(e) {};
function onClick(event) {
if(event.button == 1)
Services.appinfo.invalidateCachesOnRestart();
else if(event.button == 2)
return;
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
if(!cancelQuit.data)
Services.startup.quit(Services.startup.eAttemptQuit | Services.startup.eRestart);
}
})();
@nollinvoyd
Copy link

@rpolo77 and @you74674

Firefox 82.02

I followed the instructions.

Save config.js to Firefox installation folder, next to firefox.exe
Save config-prefs.js into \defaults\pref inside Firefox installation folder, next to channel-prefs.js
Save userChrome.js into Firefox chrome folder, next to userChrome.css
and it works

Also moved RestartFirefoxButton_Movable.uc.js to the chrome folder, but the button does not appear.

Is this still supposed to work, or am I missing something? Can someone post what the button looks like?

Copy link

ghost commented Nov 5, 2020

Did you go to Customize and add the button to your toolbar area?

@siffegh
Copy link

siffegh commented Nov 5, 2020

Button looks like this: https://prnt.sc/vdnwr0

@nollinvoyd
Copy link

nollinvoyd commented Nov 8, 2020

Guess what? I didn't have RestartFirefoxButton_Movable.uc.js in the Chrome folder after all. Dumb.

So happy. Works fine. Been hoping to find this type of restart option for a long time now.

In past custom button setups, it was possible to source the button image from a local file. I still have the previous RestartFirefoxButton_Movable.uc.js. The section of that file pertaning to the button starts with

var dataUrl = "data:image/png;base64," +

after which the base 64 code is added.

Can someone tell me if this can be done, and if so, how?

Thanks

@nollinvoyd
Copy link

I just upgraded to Firefox 89, and the restart button icon changed

Firefox 88.01

FIREFOX 88 01 RESTART

Firefox 89

FIREFOX 89 RESTART

Is there a way to bring it back?

@Gersonzao
Copy link

It doesn't work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment