Skip to content

new config.js, working in per user installation and with firefox 72+ #23

@trupf

Description

@trupf

The config.js as in this repo is not working if firefox is installed in the user account (instead of administrator). I'm not sure if it is working with current firefox (72+) at all even in standard installation as I can not test it. With attached config.js it will work again (and it should work for all installation no matter of operating system and installation path).

// 2020/01/12 config.js for loading global userChromeJS.js and users individual userChrome.js

try {

    const {
      classes: Cc,
      interfaces: Ci,
      utils: Cu
    } = Components;

    Cu.import('resource://gre/modules/Services.jsm');
    Cu.import('resource://gre/modules/osfile.jsm');

    function UserChrome_js() {
      Services.obs.addObserver(this, 'domwindowopened', false);
    };

    UserChrome_js.prototype = {
      observe: function (aSubject, aTopic, aData) {
          aSubject.addEventListener('load', this, true);
      },

      handleEvent: function (aEvent) {
        let document = aEvent.originalTarget;
        if (document.location && document.location.protocol == 'chrome:') {
		  // userChromeJS.js is just an option, the userspecific userChrome.js should be loaded anyway
		  try { let path = OS.Constants.Path.libDir;
            path = OS.Path.join(path, "userChromeJS.js");
            let uCJSFileURL = OS.Path.toFileURI(path);
		    Services.scriptloader.loadSubScript(uCJSFileURL, document.defaultView, 'UTF-8');
		  } catch(ex) {};
          let uCfile = Services.dirsvc.get('UChrm', Ci.nsIFile);
          uCfile.append('userChrome.js');
          let uCfileURL = Services.io.getProtocolHandler('file')
                        .QueryInterface(Ci.nsIFileProtocolHandler)
                        .getURLSpecFromFile(uCfile);
          Services.scriptloader.loadSubScript(uCfileURL, document.defaultView, 'UTF-8');
        }
      }
    };

    if (!Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULRuntime).inSafeMode)
      new UserChrome_js();

    } catch(e) {};

 try {
    pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
} catch(e) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions