Closed Pizzapops closed 4 years ago
Using legacy add-ons only works on Nightly, if they are still compatible like this restart add-on. It really improves testing between code modifications, thanks.
(Nightly only) about:config > extensions.legacy.enabled > true about:config > xpinstall.signatures.required > false
Also shift + f2 type restart and press enter
Sporif posted a javascript for a "Moveable Restart Button for Firefox" on GitHubGist. I haven't tinkered with it yet. My javascript knowledge is minimal. Sporif is working on Firefox Quantum compatible userChrome.js.
I adopted this useChrome.js method (->1) for my "scrollbar" tweaks a while ago. https://github.com/Aris-t2/Scrollbars
One can do a lot of stuff after importing user scripts start working incl. additional toolbars and buttons. You can find many scripts here https://github.com/ardiman/userChrome.js including a movable restart button.
@Aris-t2 Sporif's script works fine. There seems to be a conflict with Schuzak's Restart but disabling that Legacy add-on fixed the problem. My translator is going to get a workout when I check out all of Ardiman's scripts.
Restart button script - working in Firefox 62
If Firefox should use only custom script, there is way without userChrome.js loading code from inside config.js. Otherwise use code inside a restart.uc.js or similar with userChrome.js.
.\firefox\defaults\pref\config-prefs.js
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");
.\firefox\config.js
// Restart button script for Firefox 60+ by Aris
//
// left-click on restart button: normal restart
// middle-click on restart button: no special function
// right-click on restart button: no special function
//
// based on 'Quit' button code by 2002Andreas
// restart code from Classic Theme Restorer add-on
(function() {
try {
Components.utils.import("resource:///modules/CustomizableUI.jsm");
var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
CustomizableUI.createWidget({
id: "uc-restart", // button id
defaultArea: CustomizableUI.AREA_NAVBAR,
removable: true,
label: "Restart", // button title
tooltiptext: "Restart", // button tooltip title
onClick: function(event) {
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"].createInstance(Components.interfaces.nsISupportsPRBool);
var observerSvc = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
if(event.button=='0') { // only for left-clicks
observerSvc.notifyObservers(cancelQuit, "quit-application-requested", "restart");
if(cancelQuit.data) return false;
Services.startup.quit(Services.startup.eRestart | Services.startup.eAttemptQuit);
}
},
onCreated: function(button) {
return button;
}
});
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
var uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
\
#uc-restart .toolbarbutton-icon {\
list-style-image: url("chrome://browser/skin/reload.svg");\
transform: scaleX(-1);\
fill: red;\
}\
\
'), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
} catch (e) {
Components.utils.reportError(e);
};
})();
v2 with "clear caches feature"
// Restart button script for Firefox 60+ by Aris
//
// left-click on restart button: normal restart
// middle-click on restart button: restart + clear caches
// right-click on restart button: no special function
//
// based on 'Quit' button code by 2002Andreas
// restart code from Classic Theme Restorer add-on
// invalidate caches from Session Saver add-on
(function() {
try {
Components.utils.import("resource:///modules/CustomizableUI.jsm");
var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
CustomizableUI.createWidget({
id: "uc-restart", // button id
defaultArea: CustomizableUI.AREA_NAVBAR,
removable: true,
label: "Restart", // button title
tooltiptext: "Restart", // tooltip title
onClick: function(event) {
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"].createInstance(Components.interfaces.nsISupportsPRBool);
var observerSvc = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
if(event.button=='1') { // middle-click - clear caches
Components.classes["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).invalidateCachesOnRestart();
}
if(event.button=='0' || event.button=='1') { // left/middle-click - restart
observerSvc.notifyObservers(cancelQuit, "quit-application-requested", "restart");
if(cancelQuit.data) return false;
Services.startup.quit(Services.startup.eRestart | Services.startup.eAttemptQuit);
}
},
onCreated: function(button) {
return button;
}
});
// style button icon
var uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
\
#uc-restart .toolbarbutton-icon {\
list-style-image: url("chrome://browser/skin/reload.svg"); /* icon / path to icon */ \
transform: scaleX(-1); /* icon mirroring */\
fill: red; /* icon color name/code */\
}\
\
'), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
} catch (e) {
Components.utils.reportError(e);
};
})();
Looks I was wrong about items not being possible to add to Filemenu or PanelUI-button. The scripts require userChromeJS setup and only don't work with my "config.js" shortcut.
This script add a "Restart" menutiem to "File" menu: https://github.com/Endor8/userChrome.js/blob/master/addrestartbutton/addRestartButton.uc.js
I modified the above linked "Restart" item script for "File" menu and "Application" menu. It works fine with Firefox 60+ and has to be used with userChromeJS (like shown here for example).
// Restart item script for Firefox 60+ by Aris
//
// left-click on restart item: normal restart
// middle-click on restart item: restart + clear caches
// right-click on restart item: no special function
//
// based on 'addRestartButton.uc.js' script by Alice0775
// restart code from Classic Theme Restorer add-on
// invalidate caches from Session Saver add-on
var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
var RestartMenuFileAppItems = {
init: function() {
var label = "Restart";
try {
restartitem_filemenu = document.createElement("menuitem");
restartitem_filemenu.setAttribute("label", label);
restartitem_filemenu.setAttribute("id","fileMenu-restart-item");
restartitem_filemenu.setAttribute("key", "R");
restartitem_filemenu.setAttribute("insertbefore", "menu_FileQuitItem");
restartitem_filemenu.setAttribute("onclick", "if (event.button == 0) {RestartMenuFileAppItems.restartApp(false);} else if (event.button == 1) {RestartMenuFileAppItems.restartApp(true)};");
restartitem_filemenu.setAttribute("oncommand", "RestartMenuFileAppItems.restartApp(false);");
if(document.getElementById("menu_FileQuitItem").previousSibling.id != "fileMenu-restart-item" )
document.getElementById("menu_FileQuitItem").parentNode.insertBefore(restartitem_filemenu,document.getElementById("menu_FileQuitItem"));
} catch(e) {}
try {
restartitem_appmenu = document.createElement("toolbarbutton");
restartitem_appmenu.setAttribute("label", label);
restartitem_appmenu.setAttribute("id","appMenu-restart-button");
restartitem_appmenu.setAttribute("class","subviewbutton subviewbutton-iconic");
restartitem_appmenu.setAttribute("key", "R");
restartitem_appmenu.setAttribute("insertbefore", "appMenu-quit-button");
restartitem_appmenu.setAttribute("onclick", "if (event.button == 0) {RestartMenuFileAppItems.restartApp(false);} else if (event.button == 1) {RestartMenuFileAppItems.restartApp(true)};");
restartitem_appmenu.setAttribute("oncommand", "RestartMenuFileAppItems.restartApp(false);");
if(document.getElementById("appMenu-quit-button").previousSibling.id != "appMenu-restart-button" )
document.getElementById("appMenu-quit-button").parentNode.insertBefore(restartitem_appmenu,document.getElementById("appMenu-quit-button"));
} catch(e) {}
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
// style button icon
var uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
\
#appMenu-restart-button {\
list-style-image: url("chrome://browser/skin/reload.svg"); /* icon / path to icon */ \
}\
#appMenu-restart-button .toolbarbutton-icon {\
transform: scaleX(-1); /* icon mirroring */\
color: red; /* icon color name/code */\
}\
\
'), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
},
restartApp: function(clearcaches) {
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"].createInstance(Components.interfaces.nsISupportsPRBool);
var observerSvc = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
if(clearcaches) {
Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).invalidateCachesOnRestart();
}
observerSvc.notifyObservers(cancelQuit, "quit-application-requested", "restart");
if(cancelQuit.data) return false;
Services.startup.quit(Services.startup.eRestart | Services.startup.eAttemptQuit);
}
}
RestartMenuFileAppItems.init();
Edit Fixed issue with duplicating items.
Edit 2 Fixed Firefox 62 issue. (Updated method 2 from here required)
Just tested "method 2" from "Scrollbars" repository on a new browser/profile configuration and everything still works fine in Firefox 60+.
Repeat the steps mentioned here: https://github.com/Aris-t2/Scrollbars#method-2---files-for-firefox-installation-folder-and-firefox-profile-folder
Use short files names without spaces like:
\chrome\userChrome\restart_button.uc.js
\chrome\userChrome\restart_items.uc.js
Make sure file names are imported correctly \chrome\userChrome.js
:
userChrome.import("/userChrome/restart_button.uc.js", "UChrm");
userChrome.import("/userChrome/restart_items.uc.js", "UChrm");
If required, try to clean your script cache: https://github.com/Aris-t2/Scrollbars#scriptstartup-cache-must-be-deleted-after-every-change
@Aris-t2. Thx for the fix. Earlier you have mentioned that Restart item for AppButton isn't possible with config.js. Is this statement still valid or something has changed?
I could not get it to work that way. It seems the script needs a certain level of access to the main window which it only gets after userChromeJS is loaded. There might be a way to combing some stuff, but I have to run some tests first.
Edit Combining all the scripts did not work either. Most likely only stuff like this (stuff, that does not require main window / dom access) works from within config.js directly: https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm
You don't need to worry about shift + f2 much longer. See mozilla
@aabatpurdue I shared my modified restart script because of that deprecation.
Those *+#§ at Mozilla removed developer toolbar, because according to them "this feature was barely used" and those, who used it, mainly used it to restart the browser. Its actually a nobrainer to conclude people need a restart button, but they are way too focused on their "everything has to be restartless" stuff and therefore everything has to work without a restart... even if it does not.
You could change "even if" to "even when".
I found a page somewhere that implied they had nobody to maintain it and, of course, they couldn't put out the money to hire someone. As the saying goes "money, money, money, the root of all evil" or something like that (:-}).
Cleaned up thread/discussion!
@Aris-t2
I have been using Luke Baker's restart with Nuchi's XML file with both FxQ61 & FxQ62. Since XML is a Mozilla Dodo bird, I started switch over to your method 2. It works fine with FxQ61 and Ice Dragon59 but I can not get it to work with Nightly62. The App/firefox files and Chrome files are set up exactly the same as the earlier FxQ versions. I tried several profiles and some Chrome folder variations with no luck. I did a clean FxQ62 portable install. Only the App files were added and the Chrome folder with necessary Restart files. Still not working.
Did Mozilla screw up java-script on Nightly or did I miss something?
@Pizzapops Something got changed or "fixed" in Fx62, so an error inside "method 2" scripts and "restart items" script occurred.
Use the updated code above for the restart items and the updated "method 2" (v1.0.4a) from scrollbars project.
@Aris-t2 Thanks as always for the quick fix.
I followed your instructions with method 2 and I couldn't get it to work. Ultimately I'd like to use it with FF portable. Its structure is pretty much the same, but either way I couldn't get the "restart" option to even show up in the file menu.
*v62.0 - 64bit
@refriedfood. Hi, I do successfully use Restart script on FF Nightly portable (Windows). You need to do the following: FirefoxPortableNightly\App\firefox64\defaults\pref\ Update channel-prefs.js FirefoxPortableNightly\App\firefox64\ Add here config.js
FirefoxPortableNightly\Data\profile\chrome\ Add userChrome.js and userChrome folder
startupCache (needs to be cleared) folder is here FirefoxPortableNightly\Data\profile\startupCache\
I did that, too. I don't know what magic you're doing, but I certainly don't have the same spell you do.
@refriedfood Click on ItWorks and click Download. It is a clean FXNightly.zip with only JS added and has nine functioning scripts including left sidebar. Follow @Acid-Crash 's directions and clear startupCache before starting Nightly for the first time. Change the default profile in about:profiles to the profile that is included. Be careful not to delete any profiles used by other copies of Nightly.
That did it. What was missing was a proper config.js in FirefoxPortable\App\Firefox64
So:
FirefoxPortable\App\Firefox64\config.js
FirefoxPortable\Data\profile\chrome\userChrome.js
userChrome.import("/userChrome/restart_button.uc.js", "UChrm"); userChrome.import("/userChrome/restart_items.uc.js", "UChrm");
Must be in userChrome.js
FirefoxPortable\Data\profile\chrome\userChrome\userChromeJS.js & userChromeJSutilities.js & restart_items.uc.js & restart_button.uc.js
Cleared FirefoxPortable\Data\profile\startupCache
Got it. Great job, and thank you! Now if I could just get the search bar to stick on the current engine I've selected each time so I don't have to type and then click the engine each time.
https://mail.mozilla.org/pipermail/firefox-dev/2018-March/006249.html - if someone was looking for what happened to Firefox Command Line for Developers.
Don't know if this has been mentioned, but I add a bookmark for "about:profiles" to the bookmark toolbar. It has options to restart normally & restart w/ addons disabled. It's very fast for me. I keep the bookmarks toolbar hidden & instead add the "open bookmark" icon to the navbar.
I name the bookmark "Restart Fx". It only takes clicking the bookmark icon, then hovering Bookmarks Toolbar item - where it shows any BM that you added to the BM toolbar.
If you use custom js scripts, you can place a button on your toolbar. I use _restartbutton.uc.js with my "dev" profile: https://github.com/Aris-t2/CustomJSforFx/tree/master/scripts
Hi Aris-t2. I am not able to add this to FF 68. I added this into chrome/userChrome.js userChrome.import("/userChrome/restart_button.uc.js", "UChrm"); userChrome.import("/userChrome/restart_items.uc.js", "UChrm");
Then I added script from this link into userChrome/restart_items.uc.js
What should I add into userChromeJS.js file?
I created defaults/pref/config-prefs.js and added: pref("general.config.obscure_value", 0); pref("general.config.filename", "config.js"); pref("general.config.sandbox_enabled", false);
And config.js as well with:
const Cu = Components.utils;
try {
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
if (!Services.appinfo.inSafeMode) {
Services.scriptloader.loadSubScript(
OS.Path.toFileURI(OS.Path.join(OS.Constants.Path.profileDir,
"./chrome/userChrome/userChromeJS.js")), this, "UTF-8");
};
} catch(e) {};
What am I missing here?
Thanks,
Please keep the JS talk inside the corresponding area of the CustomJSforFx repository: https://github.com/Aris-t2/CustomJSforFx/issues/4
Everything you need to know is written on the main page of that repository: https://github.com/Aris-t2/CustomJSforFx/
I recommend to test M2 with a clean new Fx profile.
Thanks Aris-t2, will do. I cleared script/startup cache, and it works now.
Looks like new FF 69 broke this. :( File menu is now horizontal and missing Restart.
Test a new profile, make sure you have updated CSS files, JS methods and JS scripts, if you are using them. Also check if this pref is set correctly: 'about:config > toolkit.legacyUserProfileCustomizations.stylesheets > true'
I have the same issue with FF 69 and 70 beta. Based on Aris's comment I downloaded and copied the files from CustomJSforFx, Method 2, the restart scripts from here. Now I have 3 program folders and 4 profiles, all have this problem. The interesting thing is that the restart button works fine. Maybe the restart_items.uc.js script is causing it.
The previous FF versions didn't have this issue.
Try to setup a new test profile and make sure you are cleaning the corresponding cache folder.
All scripts work up to Fx 71 Nightly.
I've used so far the "Restart item script" and "Restart button script" you posted in this issue as text. Using the "restart_button.uc.js" and "restart_item_in_menu.uc.js" scripts from CustomJSforFx solved my horizontal File menu problem in Fx 69 and 70.
Thanks Aris!
Future script talk can be done within the script repository: https://github.com/Aris-t2/CustomJSforFx
This may work https://addons.mozilla.org/firefox/addon/restart_browser/
but need test to anti-malware in code (Moz://a
maybe failed).
I realize this may be inappropriate here but... Testing and modifying the Chrome css files requires a lot of restarting Firefox. Exiting and restarting Firefox was a nuisance. All of the restart addons on the Firefox add-ons site were labeled incompatible. Shift-F2 and type "restart" seemed to be my only option. Yesterday, I began digging through my FEBE backups trying various restart apps/versions. I did find one that works, Restart by Schuzak version 1.2.8. It provides a icon that that works, a menu bar option (under File) and a keyboard option, Alt-FR.