[JavaScript][Firefox] General JavaScript talk and custom userChrome.js scripts (v2)
Lets discuss everything related to JavaScript here instead of opening new threads for questions or request.
Continued from https://github.com/Aris-t2/CustomJSforFx/issues/4
Custom scripts https://github.com/Aris-t2/CustomJSforFx/tree/master/scripts
Other custom script collections - by ardiman - by Endor8
Hi Aris,
thank you very much for solving the latest issue with the popup width in locationbar_popup_classic_with_two_lined_results.uc.js. I had the same problem, too, but didn't have time to report. One issue still remains: If you have too many search engines installed, the width of the popup is greater than the width of URL bar (I am on FX 70.0b6).
In previous versions, the line with the search engines got wrapped.
Hope that you can fix this, too.
@jra66 Posted a new update. Forgot to limit box width of bottom search box.
Thanks for the update, Aris. Now the width of the popup is limited, but the result is even worse :grin:

Unfortunately this browser area is way too messy to fix. I can not find a proper workaround without breaking other parts of the ui in Fx70 beta.
Adopting code from Fx71 to Fx70 breaks search engine buttons context menu.
Looks like this here on 71:

You can temp. use this workaround on Fx 70 (71 does not require it), but you will lose button context menu of search engine buttons:
#urlbar .search-one-offs {
display: flex !important;
}
#urlbar .search-one-offs-context-menu {
display: none !important;
}
Removing the label will also offer some space:
#urlbar .search-panel-one-offs-header {
display: none !important;
}
EDIT New update fixes the issue with Fx70, but changes the appearance of one-off search engines area slightly. (No label and no space between engine buttons and options button)
Thanks a lot for the fixes, Aris! Now everything is fine with FX 70 beta. I don't miss the label anyway ...
Hi...
I just update my Firefox from 66 to 69. Thanks for maintaining this plugin.. :D
I had a few problems when updating to 69, on 66 I used method 1 to customize through JS, downloaded the file directly from https://github.com/nuchi/firefox-quantum-userchromejs, now this is not working. So I tried using the files from your method 1, but not working too.
Maybe Mozilla already drops XBL support?
Now I'm using method 3 and it's working.
Another thing, I don't know if this should be on CSS or JS thread because I manipulate it using JS. Please take a look on the screenshot

Can you cut the long text as shown with arrow earlier so it doesn't obstruck the icons on the right?
Thanks!
EDIT I just retried 1st method, it works fine... :D
Are you using the latest file? https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/locationbar_popup_classic_with_two_lined_results.uc.js
If yes, try to change the values here: https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/locationbar_popup_classic_with_two_lined_results.uc.js#L229
Increase 50px to 80px.
Hi @Aris-t2 Based on the following comment dues search_engine_icon_in_searchbar.uc.js needs to be updated? https://github.com/Aris-t2/CustomJSforFx/issues/11#issuecomment-539034910
To be specific I'm interested in the fix of the search icon that sometimes doesn't change during restarts
Suggestion: add the "Unlock custom CSS usage in Firefox 69 and newer
about:config > toolkit.legacyUserProfileCustomizations.stylesheets > true" from CustomCSS readme to this project readme too, at least for method 1 (didn't check the others).
note: if you saw it, yeah I first posted this in the wrong place
Hi @Aris-t2 Recently I've run into the following topic describing how to speedUp Firefox via Vacuuming SQL database files within profile https://www.reddit.com/r/firefox/comments/di51ps/a_surprising_way_to_gain_some_performance_by/ In general, I feel that whole topic might be reasonable but I'm no expert here. In one of the comments there is a hint that Vacuuming SQL databases can be executed directly from Firefox
about:support >> Go down to Places Database >> Click Verify Integrity That will vacuum the database as well as do a bunch of other checks
Could you please share your thoughts on the topic and maybe (if the whole deal is reasonable) look whether it is possible to make a script for a separate toolbar button to execute that "Verify Integrity" command from about:support?
Reducing size of huge database files might speedup browser start, not I'm not sure, if this will be a noticeable speedup.
Haven't looked much into creating a button, but this code is used inside aboutSupport.js
ChromeUtils.defineModuleGetter(
this,
"PlacesDBUtils",
"resource://gre/modules/PlacesDBUtils.jsm"
);
button = $("verify-place-integrity-button");
if (button) {
button.addEventListener("click", function(event) {
PlacesDBUtils.checkAndFixDatabase().then(tasksStatusMap => {
let logs = [];
for (let [key, value] of tasksStatusMap) {
logs.push(`> Task: ${key}`);
let prefix = value.succeeded ? "+ " : "- ";
logs = logs.concat(value.logs.map(m => `${prefix}${m}`));
}
$("verify-place-result").style.display = "block";
$("verify-place-result").classList.remove("no-copy");
$("verify-place-result").textContent = logs.join("\n");
});
});
}
Most likely importing resource://gre/modules/PlacesDBUtils.jsm and applying PlacesDBUtils.checkAndFixDatabase() to buttons click even should be enough.
I'm on the latest release for Firefox and am currently in use of the 1st method for custom JS. Is there a known roadmap for dropping XBL support? I don't like waiting for the rug to be pulled from under.
Nothing I heard of yet, but there always might be a Bugzilla thread/bug tracing such changes.
In the past, I tried in favicon_in_urlbar.uc.js to load the sheet icon from CustomCSSforFx.
But I wasn't very satisfied with having to hardcode the path to the image, thus making the script not transferable to another computer without having to update it accordingly.
I finally found the answer to that:
var sheet2 = 'file:///' +
Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path.replace(/\134/g,'/') +
'/chrome/image/tab_favicon_sheet.png';
The code to convert the calculated profile path from using \ to using / was very annoying to find, but like that, it worked as I wanted it. I don't know if others users would have been interested in this, but if it's the case, the code is now available : )
@Aris-t2
While searching Reddit for inspiration, I found a moveable appbutton script posted by u/Diab01ica1. Using method 2 JS, it is very functional and can be placed on the titlebar, tabbar, navbar or an addonbar. To use on the tab bar, it should be dropped on the first tab. The original script used menu.svg for the icon but I changed it to welcome-back.svg (small running fox seen below). It needs version appropriate button.
movable-menu-button.uc.zip

Followup: 68esr needs menu.svg (hamburger icon) for script to work.
Followup_2: There seems to be a conflict with this js & and a file used by userChrome.css of CustomCSSfor FX. If the icon is moved to the tabs bar, the running fox icon does not show. Switch to menu.svg.
Partial fix: I found the conflicting file. Classic_squared_tabs...... was the problem. I deactivated them in userChrome.css and the script works now in the tab bar. I also switched the icon to the version icon.
appbutton_movable.uc.zip Enjoy!
Nice find.
@Aris-t2
I found the conflict with classic_squared_tabs.css. Padding, height & width are unset in lines 356-360 and lines 373-377 in classic_squared_tabs_australized.css. Commenting them out works but I prefer to change the padding to 2px and the height & width to 28px for a bigger icon.
Any potential problems with this approach?
If you do not have any buttons on tabs toolbar besides the new appbutton, everything should work fine.
Not liking the new Search engine button mess (ff 70)...
Is there currently any known way to get the 69 implementation back? I don't see the need to have my default listed as an icon on this list... I already known how to use it. Mozilla and their random changes again.
There is no general code to hide your selected engine, but you can hide those you do not need by using code like this (enter the Engine name showing in the tooltip when you hover a button):
.search-panel-one-offs button[tooltiptext="Google"] {
display: none !important;
}
I also suggest to cleanup that area in general using this code:
/* reduce space around search engines */
#urlbar .search-one-offs {
padding-top: 0px !important;
padding-bottom: 0px !important;
padding-inline-start: 4px !important;
padding-inline-end: 0px !important;
}