Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
trupf opened this issue Jan 14, 2020 · 0 comments
Open

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

trupf opened this issue Jan 14, 2020 · 0 comments

Comments

@trupf
Copy link

trupf commented Jan 14, 2020

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) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant