9
submitted 1 week ago by cm0002@lemmy.zip to c/firefox@fedia.io

There weren't any straightforward guides when I looked this up, and I even had to ask myself. But I just needed to put so and so together, get some feedback here, and voila! Hopefully this can work for you too, and could edit userchrome.css in your favorite editor, and see the changes in Firefox immediately. I tested that it works with @import url("folder/file.css");, and nested imports too (if folder/file.css contained @import url("Another folder/file.css");.

  1. Install fx-autoconfig (I haven't tested it with other Firefox JS loaders), following the whole install section: https://github.com/MrOtherGuy/fx-autoconfig?tab=readme-ov-file#install
  2. In the chrome/JS/ folder, create <any file name>.uc.mjs (I named mine refresh.uc.mjs) and paste the script below (it's slightly modified from this snippet): * The part containing @onlyonce is needed so fx-autoconfig loads it just once, rather than spawn a new instance of the script every time a new firefox window is opened.
  3. Clear startup cache: https://github.com/MrOtherGuy/fx-autoconfig?tab=readme-ov-file#deleting-startup-cache
  4. You may need to toggle the script. You can go to Menu Bar > Tools > userScripts.

Script

// ==UserScript==
// @onlyonce
// ==/UserScript==

// Script from here:  https://gist.github.com/jscher2000/ad268422c3187dbcbc0d15216a3a8060?permalink_comment_id=3259657#gistcomment-3259657
setInterval(() => {
    /*
       Code to paste and run in the Browser Console
       Requires devtools.chrome.enabled => true in about:config
       Tested in Firefox 68.0.1 on Windows
    */

    // Create references to APIs we'll use
    var ss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
    var io = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var ds = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
      
    // Get the chrome directory in the current profile
    var chromepath = ds.get("UChrm", Ci.nsIFile);

    // Specific file: userChrome.css or userContent.css
    chromepath.append("userChrome.css");

    // Morph to a file URI
    var chromefile = io.newFileURI(chromepath);

    // Unregister the sheet
    if(ss.sheetRegistered(chromefile, ss.USER_SHEET)){
      ss.unregisterSheet(chromefile, ss.USER_SHEET);
    }

    // Reload the sheet
    ss.loadAndRegisterSheet(chromefile, ss.USER_SHEET);
}, 1000)

OC by @TheTwelveYearOld@lemmy.world

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here
this post was submitted on 13 Dec 2025
9 points (100.0% liked)

Firefox

4 readers
23 users here now

The latest news and developments on Firefox and Mozilla, a global non-profit that strives to promote openness, innovation and opportunity on the web.

You can subscribe to this community from any Kbin or Lemmy instance:

Related

Rules

While we are not an official Mozilla community, we have adopted the Mozilla Community Participation Guidelines as far as it can be applied to a bin.

Rules

  1. Always be civil and respectful
    Don't be toxic, hostile, or a troll, especially towards Mozilla employees. This includes gratuitous use of profanity.

  2. Don't be a bigot
    No form of bigotry will be tolerated.

  3. Don't post security compromising suggestions
    If you do, include an obvious and clear warning.

  4. Don't post conspiracy theories
    Especially ones about nefarious intentions or funding. If you're concerned: Ask. Please don’t fuel conspiracy thinking here. Don’t try to spread FUD, especially against reliable privacy-enhancing software. Extraordinary claims require extraordinary evidence. Show credible sources.

  5. Don't accuse others of shilling
    Send honest concerns to the moderators and/or admins, and we will investigate.

  6. Do not remove your help posts after they receive replies
    Half the point of asking questions in a public sub is so that everyone can benefit from the answers—which is impossible if you go deleting everything behind yourself once you've gotten yours.

founded 2 years ago
MODERATORS