Run userchrome.js scripts in Firefox 57 or newer

Martin Brinkmann
Nov 24, 2017
Updated • Nov 25, 2017
Firefox
|
16

If you have used a browser extension such as userChrome.js in the past to run JavaScript code in the browser context; handy to manipulate functionality of the browser directly.

A huge list of scripts was created that Firefox users could load using the extension. These scripts changed elements of the Firefox user interface, dialogs, and other features of the browser.

The release of Firefox 57 blocks extensions like userChrome.js. Someone figured out how to restore the functionality in Firefox 57 and newer versions.

It needs to be noted that Mozilla may plug this hole at any time, and that scripts may stop working because of that eventually.

Here is how it works

Download the three userChrome.* files from the project's GitHub repository and place them in the chrome folder of the Firefox profile.

If you make use of some of these files already in the folder copy the content of them and paste them to add them to your files in the folder.

You can open the profile folder of Firefox by loading about:support in the browser's address bar. There you find the "open folder" button which you need to activate to open the Firefox profile folder using the default file manager of the system. If the chrome folder does not exist (it does not by default), create it, and place the files in the folder afterwards.

The author describes how the workaround works on the project page:

It relies on the fact that post-57 Firefox still allows a custom userChrome.css file, and a Firefox-specific CSS hack which can bind javascript to arbitrary DOM elements. I picked (somewhat at random) a DOM element in the browser whose existing XBL binding didn't already have a <constructor> tag, and added some JS there to load an external javascript file.

It's very possible that at some future time the Firefox team will remove some or all of the functionality that makes this possible, so enjoy it while you can.

You need to add what you want to executed to the userChrome.js file. You may want to check out this Firefox 57 scripts repository, all of which should work with Firefox 57 and newer versions of the browser.

Simply copy the code from any script and restart Firefox afterwards. The script is run then by Firefox.

Summary
Run userchrome.js scripts in Firefox 57 or newer
Article Name
Run userchrome.js scripts in Firefox 57 or newer
Description
Find out how to run userChrome.js JavaScript code in Firefox 57 and newer versions of the web browser by Mozilla.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. I hate commies said on November 27, 2017 at 8:39 pm
    Reply

    to use metaphor It’s like Mozilla has created a “Mona Lisa” everyone loved it.
    Everyone.

    Then one day they said, we’ll it’s time to put this on another wall.
    But instead of using moly bolts and making a nice strong lift the way your supposed to, they just grabbed four long Drywall screws and went right through the picture into the wall at each corner.

    Is the mona lisa nice still?
    Or should I attempt to turn down the lights and bring touch up paint?
    What about the value? You ain’t cleaning that with a potato.

    So. You want me to take it down in a couple a years or so? Sure, Can you pass the box knife?
    Look now it fits in a tube.
    AND ITS FASTER!

  2. I hate commies said on November 27, 2017 at 8:14 pm
    Reply

    should been more clear , we do not hate ghacks. We thank ghacks (I know it don’t look like a thanks)
    I don’t really come to ghacks to get angry at people. Mozilla has perhaps triggered me this morning. Usually all the sec updates and annoyances don’t all happen like nine planets lining up. And it seems like every time I “depend” on a mozilla based thing I am forced to screw with it for the first fifteen minutes trying to get it to just behave like I left it last. without it changing things behind my back. I get it the green horns can’t handle keeping js, j, flash, gl, rtc, sl, c, i, a, cs, proxies straight in their mind so when when they want something like quickjava to be uninstalled they say they want a “default” settings again–this is an impossible request- we can make “fake settings who have it all turned on” Mypluginthing = “1” which is the best answer. But where we get into real problems is where we have quickjava in the process of completing a task (which goes forever) and along comes mozilla and says this thing has to go and I don’t care what IT (quickjava/or MYpluginthing) has done to the settings. SO mozilla is the moron. mozilla is the one causing security problems. After all I had all these mypluginthing’s going for more than a decade with no security problem, and the only “stability problems” have been when mozilla updates and destroys the under-laying foundation.

    It’s like taking MOV away from assembly language.
    now go fix your scripts.

    Those who quickly want to focus on quickjava – don’t. QJ was only an example among many extensions all with similar problems. I probably should have cut that path off in the first sentence.

    Please, Don’t spit in anyone’s sandwich. But I still hate them. I don’t won’t be so nice and I will treat all their “issues” with contempt from the beginning no matter the topic they have this POOP around their ankles to begin with

    I hope that tones down my last post.

    1. Tom Hawack said on November 27, 2017 at 8:49 pm
      Reply

      As users we’re all on the same side here, as on most blogs. Your exasperation is understandable even if you might have expressed them straightforwardly this morning, as you recognize it, and even if we’ve read far worse. Your comment hasn’t been censored because the general tone is far less taken into consideration than deliberate insults, troll etc (you see what I mean). It got, gets you upset and you said your truth, with ’em words, but I guess there’s no hard feeling because no one was targeted here.

      No news to repeat that many, but really many users are annoyed (to put it mildly) by the turn of Mozilla’s policy concerning its Firefox browser. But once we’ve expressed our exasperation we have to carry on, right? That’s what Ghacks is all about, helping us all and letting us help one another throughout our posts.

      Firefox 57 is a fact. Either we accept Firefox 57, either we stick on Firefox ESR 52, either we choose a “fork” such as Pale Moon, Waterfox, Cyberfox … we’ve been debating over this here and continue to. Pros and cons whatever the choices, IMHO no best/right choice, it’s up to each of us to try to find the best way to conciliate our needs, our wishes, our personal aptitudes, our determination to work hard to get all these parameters fitting correcly.

      Stay tuned, you’ll always find pertinent information here. Take care!

  3. I hate commies said on November 27, 2017 at 7:22 pm
    Reply

    There’s not much to say about Mozilla they were circling the toilet but now in the sewer on way to sewage treatment plant.

    Looking for a new extension? Tough

    Feel like switching to a UserChrome.Css ? Meet -moz-appearance:
    Missing == Removed by marxist communist programmers

    all addons have a security/stability (marxist communist programmer @mozilla ) problem now (I can tell they all have warnings.)

    Middle finger upon the mozilla programmers and their human waste narrative.

    I actually hope bad stuff happens to them all–every one that had something to do with this.
    If I made sandwiches for you, I would spit in your sandwich.

    This isn’t oh I’ll just go away, I HATE YOU NOW.
    reverse this BS.

    ps: FOXDIE Clone progress.
    http://i.imgur.com/ToEg3Tc.png
    (it’s mostly userscript, some CTR toggles)
    running on Basilisk (latest)

    code
    https://pastebin.com/xHb0p1uH

  4. Anonymous said on November 25, 2017 at 7:30 am
    Reply

    Ghacks is buggy. Randomly a lot of posts appears only 24h later or even more. Sometimes they don’t appears at all.

  5. Jack E. Alexander said on November 25, 2017 at 4:26 am
    Reply

    Why bother? Firefox ceased to be a browser of choice when they released version 57. Whoever did this to the browser should buy some rope and hang themselves. FX had been my choice since one of the very earliest versions. I won’t be using it anymore. I’ll use the new Basilisk browser from Moonchild productions. It seems like it is a viable choice. In the meantime, I am using Waterfox which works very well. I get a giggle out of sites that say my browser needs to be updated. Those sites have no idea what kind of security I use on my machines.

    Bye, bye Firefox…. loser!

    1. Felina Erse said on November 25, 2017 at 7:03 pm
      Reply

      Firefox used to work best for me. Unfortunately the Firefox programmers have ruined a once good browser.

      1. Feline Arse said on November 26, 2017 at 4:13 pm
        Reply

        Can I get on the boohoo bandwagon too ? Firefox has never been that good for me. Ah crap, I failed to hop on.

        See you at the next station then! Sounds like it should be around Firefox ~61.

  6. Tustamido said on November 25, 2017 at 3:06 am
    Reply

    Firefox always had a native userChromeJS named autoconfig.js (or config.js, mozilla.cfg… different names for the same thing).

    gHacks itself promote it here for a specific purpose:
    https://www.ghacks.net/2016/08/14/override-firefox-add-on-signing-requirement/

    The repository listed in this article (there are many more on GitHub and other sites, the best known is https://github.com/alice0775/userChrome.js) contains instructions (in German) that work in Firefox 57:
    https://github.com/Endor8/userChrome.js/tree/master/userChrome

    autoconfig.js is more reliable than hacking element bindings with userChrome.css (Mozilla is removing XBL from Firefox, see https://arewexblstill.com/). And more powerfull too, since it have full power, can run JS code even before Firefox window opens and in other windows like download dialog and Places Library.

    1. Zip said on November 25, 2017 at 9:18 pm
      Reply

      So basically autoconfig.js can do anything that the legacy userChrome.js could, and unlike the method presented in the article it’s not a hack and should stay supported by Mozilla ?

      If so, sounds like it’s worth an article down the line… :)

    2. Richard Allen said on November 25, 2017 at 12:59 pm
      Reply

      Thanks for the links.

  7. Borgy said on November 25, 2017 at 12:29 am
    Reply

    I’m using Stylus which works fine with 57+.

  8. TelV said on November 24, 2017 at 4:58 pm
    Reply

    The chrome folder isn’t present by default Martin and has to be created. Or at least that was the case pre-FF57.

    1. Cloudman said on November 25, 2017 at 11:07 am
      Reply

      It’s still the case.

  9. Tom Hawack said on November 24, 2017 at 4:48 pm
    Reply

    That’s what I’d immediately consider if I were a Firefox 57+ user.
    There’s also a dedicated userChrome.css editor proposed as an extension, which runs with “Firefox 42.0 and later” (hence 57+) : ‘FxUI Editor’ [https://addons.mozilla.org/en-US/firefox/addon/fxui-editor/] — I haven’t tried it because as a pre-57 user I’m still entitled to use the Stylish add-on as it was previously to its version 3+ update, catastrophic as the users’ feedback report it, and of which I’ve changed the version number to 9.9.9 in order to not have it updated (Stylish 3.0.1 runs on Firefox 48+ and when I had it updated here on Waterfox 55 it took me 10 seconds to realize te chaos and quickly recover backedup profile …

    So this article will contribute to help poor Firefox 57 fellas dealing with their browser’s interface, with whom I sympathize (irony-free).

    1. Zip said on November 25, 2017 at 9:20 pm
      Reply

      I see the effort you deployed to get your browser super customised. I too was able to super customise my browser. It’s Firefox 57. I just copy pasted some code to get it, and tweaked some numbers here and there because why not ? If I want my Ferrari painted in 148 colors with my name written on it, or if I want the doors to open vertically instead of horizontally, I can get that.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.