xiaoxiaoflood / firefox-scripts

userChromeJS / autoconfig.js and extensions
Mozilla Public License 2.0
954 stars 83 forks source link

Waterfox G4.1.3 (64-bit) "Configuration Error" #149

Open CortexReaver opened 2 years ago

CortexReaver commented 2 years ago

After installing userChromeJS and clearing startup cache, Waterfox throws me this error. Seems like previous versions also does, but at least extensions there works fine. Done everything by the instruction.

23-06-2022 194421

xiaoxiaoflood commented 2 years ago

Next Fx ESR (v102) will be released in less than a week so maybe it's not worth a proper fix.

As for now there are multiple ways to fix this. One of them is to use an older version of config.js.

Other is to remove all these lines: https://github.com/xiaoxiaoflood/firefox-scripts/blob/7f4e96000baf44398e7308b0aed24781ec29ea82/installation-folder/config.js#L5-L9

Other is to replace ChromeUtils here https://github.com/xiaoxiaoflood/firefox-scripts/blob/7f4e96000baf44398e7308b0aed24781ec29ea82/installation-folder/config.js#L6 by Cu.getGlobalForObject(Cu).ChromeUtils or even just Cu.

jis5ey commented 2 years ago

I have the same issue in Waterfox 4.1.3.1 but also, I've noticed that I don't have anymore the button in the toolbar which I used to enable/disable custom scripts. EDIT: As suggested by xiao, I've replaced ChromeUtils.import('resource://gre/modules/AppConstants.jsm') by Cu.getGlobalForObject(Cu).ChromeUtils and now it fixes everything. All good 👌

onemen commented 2 years ago

@xiaoxiaoflood, we can check if we are in Waterfox and skip BootstrapLoader

// skip 1st line
lockPref('xpinstall.signatures.required', false);
lockPref('extensions.install_origins.enabled', false);

const {Services} = Cu.import("resource://gre/modules/Services.jsm");
const isWaterFox = Services.appinfo.name === "Waterfox"

try {
  let cmanifest = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get('UChrm', Ci.nsIFile);
  cmanifest.append('utils');
  cmanifest.append('chrome.manifest');
  Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(cmanifest);

  if (!isWaterFox) {
    // signing bypass by onemen
    const Constants = Cu.import('resource://gre/modules/AppConstants.jsm');
    const temp = Object.assign({}, Constants.AppConstants);
    temp.MOZ_REQUIRE_SIGNING = false;
    Constants.AppConstants = Object.freeze(temp);

    Cu.import('chrome://userchromejs/content/BootstrapLoader.jsm');
  }
} catch (ex) { };

try {
  Cu.import('chrome://userchromejs/content/userChrome.jsm');
} catch (ex) { };
xiaoxiaoflood commented 2 years ago

Yes, thanks, but my reasoning is as follows: Waterfox don't need these files to install legacy extensions, they are natively supported. These file are required by Firefox users who want to run legacy extensions OR anyone wanting to run userChromeJS scripts.

That's OK, except that this is just a personal project I share for anyone who finds it useful. I use Fx Developer Edition, so DevEd is the only compatibility target. Or almost, because I also want userChromeJS, rebuild_userChrome and StyloaiX to be compatible with Thunderbird, which is based on ESR, so these are the only exceptions.

If I add something explicitly targeting Waterfox, users will expect that things here should be compatible with Waterfox and that's not the case, to simplify maintenance I always stated that I don't retain compatibility with versions other than DevEd.

For extensions this is easy to handle because there are compatibility flags in install.rdf, so users from an old version like Waterfox simply aren't notified when there's an unsupported update for an legacy extension. But for userChromeJS scripts there is no control.

So I might add this code, but doing that would probably cause misunderstanding i.e. wrong bug reports.

xiaoxiaoflood commented 2 years ago

Or better. Since signing bypass is only required for loading legacy extensions, I can simply move the code away from config.js and put it in BootstrapLoader.jsm.

Done in 2bf4334a604ef2184657ed1ddf512bbe0cd7c63c.

onemen commented 2 years ago

Or better. Since signing bypass is only required for loading legacy extensions, I can simply move the code away from config.js and put it in BootstrapLoader.jsm.

It does not work in Firefox 102.

Every Firefox code that imports AppConstants.jsm before BootstrapLoader.jsm runs will have MOZ_REQUIRE_SIGNING set to true.

onemen commented 2 years ago

@xiaoxiaoflood, did you read the previous post ?

xiaoxiaoflood commented 1 year ago

@onemen

It always worked for me. It's working in Fx 104 DevEd and also in 102 release. BootstrapLoader.jsm runs very early. It would only be a issue for bootstrapLoader.xpi, but if you're able to install bootstrapLoader.xpi is because signing requirement is already disabled (DevEd, Nightly or unbranded) so doesn't matter.