CustomJSforFx icon indicating copy to clipboard operation
CustomJSforFx copied to clipboard

[JavaScript][Firefox] General JavaScript talk and custom userChrome.js scripts (v2)

Open Aris-t2 opened this issue 7 years ago • 305 comments

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

Aris-t2 avatar Sep 17 '19 16:09 Aris-t2

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).

Bild 002 In previous versions, the line with the search engines got wrapped.

Hope that you can fix this, too.

jra66 avatar Sep 17 '19 20:09 jra66

@jra66 Posted a new update. Forgot to limit box width of bottom search box.

Aris-t2 avatar Sep 18 '19 15:09 Aris-t2

Thanks for the update, Aris. Now the width of the popup is limited, but the result is even worse :grin:

Bild 003

jra66 avatar Sep 18 '19 19:09 jra66

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: 1

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)

Aris-t2 avatar Sep 18 '19 20:09 Aris-t2

Thanks a lot for the fixes, Aris! Now everything is fine with FX 70 beta. I don't miss the label anyway ...

jra66 avatar Sep 19 '19 09:09 jra66

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

Screenshot_2

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

zom243 avatar Sep 24 '19 00:09 zom243

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.

Aris-t2 avatar Sep 24 '19 05:09 Aris-t2

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

Acid-Crash avatar Oct 07 '19 14:10 Acid-Crash

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

BoomerangAide avatar Oct 07 '19 15:10 BoomerangAide

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?

Acid-Crash avatar Oct 16 '19 12:10 Acid-Crash

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.

Aris-t2 avatar Oct 16 '19 13:10 Aris-t2

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.

That-Random-Guy avatar Oct 20 '19 16:10 That-Random-Guy

Nothing I heard of yet, but there always might be a Bugzilla thread/bug tracing such changes.

Aris-t2 avatar Oct 20 '19 16:10 Aris-t2

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 : )

BoomerangAide avatar Oct 21 '19 15:10 BoomerangAide

@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 2019-10-21_121222

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. appbutton_movable 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!

Pizzapops avatar Oct 21 '19 17:10 Pizzapops

Nice find.

Aris-t2 avatar Oct 21 '19 18:10 Aris-t2

@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. 2019-10-25_142141 Any potential problems with this approach?

Pizzapops avatar Oct 25 '19 19:10 Pizzapops

If you do not have any buttons on tabs toolbar besides the new appbutton, everything should work fine.

Aris-t2 avatar Oct 25 '19 19:10 Aris-t2

Not liking the new Search engine button mess (ff 70)...

ff_70_search 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.

That-Random-Guy avatar Oct 26 '19 04:10 That-Random-Guy

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;
}

Aris-t2 avatar Oct 26 '19 09:10 Aris-t2