this post was submitted on 11 Aug 2023
424 points (99.5% liked)

Firefox

4128 readers
16 users here now

A community for discussion about Mozilla Firefox.

founded 1 year ago
MODERATORS
 

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 11 months ago

To complete this, probably with ff117 I had to fix the way I load my userchrome files, reminding me I should probably put them here too:

/usr/lib64/firefox/firefox.cfg

// firefox.cfg file needs to start with a comment line
// it is included by having the following two lines in defaults/pref/autoconfig.js:
// pref("general.config.sandbox_enabled", false);
// pref("general.config.filename", "firefox.cfg");
// pref("general.config.obscure_value", 0);

var Services = globalThis.Services;
Services.obs.addObserver((aSubject, _aTopic, _aData)=>{
  var chromeWindow = aSubject;
  chromeWindow.setTimeout(()=>{
    try {
      if (chromeWindow.userChromeJsMod) return;
      chromeWindow.userChromeJsMod = true;
      var chromeFiles = chromeWindow.FileUtils.getDir("UChrm", []).directoryEntries;
      var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
      while (chromeFiles.hasMoreElements()) {
        var file = chromeFiles.getNext().QueryInterface(Components.interfaces.nsIFile);
        var fileURI = Services.io.newFileURI(file);
        if (!file.isFile()) continue;
        
        if (/(^userChrome|\.uc)\.js$/i.test(file.leafName)) {
          // load userChrome.js and *.uc.js (case insensitive) as js file
          Services.scriptloader.loadSubScriptWithOptions(fileURI.spec, {
            target: chromeWindow,
            charset: "UTF-8",
            ignoreCache: true,
          });
        } else if (/\.as\.css$/i.test(file.leafName)) {
          // load *.as.css (case insensitive) as css file (in browser scope)
          if (!sss.sheetRegistered(fileURI, sss.AGENT_SHEET)) {
            sss.loadAndRegisterSheet(fileURI, sss.AGENT_SHEET);
          }
        } else if (/^(?!(userChrome|userContent)\.css$).+\.css$/i.test(file.leafName)) {
          if (!sss.sheetRegistered(fileURI, sss.USER_SHEET)) {
            sss.loadAndRegisterSheet(fileURI, sss.USER_SHEET);
          }
        }
      }
    } catch (e) {
      Components.utils.reportError(e); // [check] Show Content Messages
    }
  }, 10);  // end of timeout
}, "browser-delayed-startup-finished", false);

/usr/lib64/firefox/defaults/pref/autoconfig.js

pref("general.config.sandbox_enabled", false);
pref("general.config.filename", "firefox.cfg");
pref("general.config.obscure_value", 0);