[Ext] userChromeJS 2.0 [2015-08-02]

Announce and Discuss the Latest Theme and Extension Releases.
Locked
User avatar
Endor
Posts: 146
Joined: January 17th, 2008, 8:03 am
Location: Somewhere in Space

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by Endor »

Hi alta88.
Will the userchromejs.2.0.xpi add-on survive the transition to webextension
or is it destined to die? Are there any news about this?
Cheers
Endor
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
OS: Windows 7 Home Premium - My Versions Info
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by alta88 »

I haven't looked into it, but from what I understand it won't/can't be as privileged as it is currently. It can likely be made to execute snippets of code but not on chrome or using xpcom apis, ie I doubt it can add an xul statusbar to the dom, etc. so won't be hugely useful. And the xul overlay part is surely dead. For web page manipulation, whatever GreaseMonkey can do is an alternative. I'm also unlikely to take the time to figure it out/convert it, sorry.

The current state of thinking is well described by the door slam on the old bug to implement natively a userChrome.js type file:
https://bugzilla.mozilla.org/show_bug.cgi?id=332529
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by morat »

The config file may still work in Firefox 57. You can use the mozilla.cfg file as an alternative to the userChrome.js file.

Customizing Firefox – Advanced Autoconfig Files
http://mike.kaply.com/2012/03/22/custom ... fig-files/

Demo mozilla.cfg file
http://mike.kaply.com/wp-content/blogs. ... 2/demo.cfg

Observer Notifications
http://developer.mozilla.org/en-US/docs ... ifications

Deploying Firefox in an enterprise environment
http://developer.mozilla.org/en-US/Fire ... deployment
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by alta88 »

Thanks morat, .cfg is indeed a way to bypass being an xul overlay. However,
1) a web extension would need to write to this file, this ability could be removed in the future.
2) the code executed in .cfg could be limited to just the pref setting/locking for which the file was originally intended.
aborix
Posts: 29
Joined: October 23rd, 2017, 1:23 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by aborix »

Hi everybody.

In a german forum we are talking about the subject:
https://www.camp-firefox.de/forum/viewt ... 7#p1053287

We make script loading possible with the config file and a folder with three files.

The config file:

Code: Select all

//

const Cu = Components.utils;

try {

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

  if (!Services.appinfo.inSafeMode) {
    let path = OS.Constants.Path.libDir;
    if (Services.appinfo.OS == 'Darwin') {  // macOS
      path = OS.Path.join(OS.Path.dirname(path), "Resources");
    };
    var ucjsDirPath = OS.Path.join(path, "userChromeJS");
    path = OS.Path.join(ucjsDirPath, "main.js");
    let mainFileURI = OS.Path.toFileURI(path);
    Services.scriptloader.loadSubScript(mainFileURI, this, "UTF-8");
  };

} catch(e) {
  Cu.reportError(e);
};
Two files of the folder contain the JS code from the extension with some modifications. The third file is the readme. The folder is named "userChromeJS" and you can download it zipped here:

http://s000.tinyupload.com/?file_id=034 ... 5500264989

Unpack it and then put it into the installation directory.
Take a look at the readme, a new function for imported scripts is added.

Have fun! :)

Edit: config file modified. The old one did not work for macOS.
Last edited by aborix on December 10th, 2017, 2:22 pm, edited 1 time in total.
pintassilgo
Posts: 200
Joined: August 30th, 2013, 3:50 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by pintassilgo »

jikamens
Posts: 25
Joined: December 7th, 2011, 8:34 am

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by jikamens »

Man, a huge, jumbled MozillaZine forum thread is a really poor mechanism for supporting an add-on.

Is anybody still maintaining this add-on?

Even if it stops working in Firefox, it is continuing to work in Thunderbird, and I'd really like to keep using it.

But then there's this error it's currently generating in Thunderbird:

JavaScript error: chrome://userchromejs/content/userChromeJS.js, line 214: TypeError: date.toLocaleFormat is not a function

Sure would be nice if this were fixed.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by morat »

Many thanks to aborix and pintassilgo.

@jikamens

Workaround:

* content\userChromeJS.js

Code: Select all

get date() {
  let date = new Date();
  try {
    date = date.toLocaleFormat(this.dateFormat);
  } catch (e) {
    date = date.toString();
  }
  return date;
},
Add-ons Guide for Thunderbird 57
http://wiki.mozilla.org/Thunderbird/Add-ons_Guide_57
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by morat »

Someone got the userChrome.js file working with only the userChrome.css 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.
Firefox Quantum compatible userChrome.js
http://github.com/Sporif/firefox-quantum-userchromejs
http://gist.github.com/Sporif

Luke Baker customizations
http://luke-baker.github.io/
User avatar
DanRaisch
Moderator
Posts: 127187
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: [Ext] userChromeJS 2.0 [2015-08-02]

Post by DanRaisch »

Locking this thread at the request of the original poster.
Locked