Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
}
})();
@Skrity

This comment has been minimized.

Copy link

@Skrity Skrity commented Dec 13, 2017

This icon seem fitting, and can blend nicely with current theme: chrome://browser/skin/sync.svg

@rayman89

This comment has been minimized.

Copy link

@rayman89 rayman89 commented Apr 18, 2018

I was not able to make the button work. It only appears as a button not on the menu and clicking it does nothing. Any idea why?

@Eternal73

This comment has been minimized.

Copy link

@Eternal73 Eternal73 commented Sep 7, 2018

Seems FF63 destroyed this, the icon has vanished from the toolbar....

@intika

This comment has been minimized.

Copy link

@intika intika commented Nov 24, 2018

One simple solution is to bookmark "about:profiles" ... when restart is needed open that page and click "normal restart"

capture
...

@rpolo77

This comment has been minimized.

Copy link

@rpolo77 rpolo77 commented Dec 4, 2019

button stopped showing up in firefox 72

@siffegh

This comment has been minimized.

Copy link

@siffegh siffegh commented Dec 5, 2019

Confirmed; it had stopped appearing in Nightly too.

@Sporif

This comment has been minimized.

Copy link
Owner Author

@Sporif Sporif commented Dec 5, 2019

@siffegh @rpolo77 Firefox 72 removed support for XBL, so the userchromejs method for injecting scripts found here or here no longer works.

@siffegh

This comment has been minimized.

Copy link

@siffegh siffegh commented Dec 6, 2019

:-( Got any more magic tricks? FF sure is antagonizing lots of users with their ridiculous restrictions lately.

@you74674

This comment has been minimized.

Copy link

@you74674 you74674 commented Dec 13, 2019

@siffegh

This comment has been minimized.

Copy link

@siffegh siffegh commented Dec 14, 2019

If only I knew what I need from there, and how to implement it :-(

@rpolo77

This comment has been minimized.

Copy link

@rpolo77 rpolo77 commented Dec 14, 2019

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

@siffegh

This comment has been minimized.

Copy link

@siffegh siffegh commented Dec 16, 2019

and it works

Yes - yes, it does :-) Thanks for the help, @rpolo77 and @you74674.

@Beckfield

This comment has been minimized.

Copy link

@Beckfield Beckfield commented Jan 24, 2020

The solution provided by you74674, and the instructions from rpolo77, works great on Windows. I tried saving the same files in the equivalent locations (hopefully) on my Linux MInt system, but it doesn't work. Either I have something wrong, or this just won't work on Linux. Any thoughts? I'm guessing the problem(s) may be within the .js files themselves, but I'm not strong on that kind of work.

config.js is in /usr/lib/firefox, next to firefox.sh
config-prefs.js in /usr/lib/firefox/defaults/pref, next to channel-prefs.js
userChrome.js in /home/ken/.mozilla/firefox/[profile].default/chrome, next to userChrome.css

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Sep 26, 2020

Restart restored, thank you all so much. I had upgraded to 78.3esr and it broke userchrome and the restart button.

Tabs on the top again, those ba****rds!!!

@nollinvoyd

This comment has been minimized.

Copy link

@nollinvoyd nollinvoyd commented Nov 5, 2020

@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?

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Nov 5, 2020

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

@siffegh

This comment has been minimized.

Copy link

@siffegh siffegh commented Nov 5, 2020

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

@nollinvoyd

This comment has been minimized.

Copy link

@nollinvoyd 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

This comment has been minimized.

Copy link

@nollinvoyd nollinvoyd commented May 31, 2021

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?

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