xiaoxiaoflood / firefox-scripts

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

Preparation for Firefox 117 #265

Open onemen opened 1 year ago

onemen commented 1 year ago

@xiaoxiaoflood

Firefox 117 changes

firefox-scripts will stop working on Firefox 117 without these changes

Update utils

BootstrapLoader.jsm

 let EXPORTED_SYMBOLS = [];

 const { XPCOMUtils } = ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm');
+const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;

 XPCOMUtils.defineLazyModuleGetters(this, {
   Blocklist: 'resource://gre/modules/Blocklist.jsm',
   ConsoleAPI: 'resource://gre/modules/Console.jsm',
   InstallRDF: 'chrome://userchromejs/content/RDFManifestConverter.jsm',
-  Services: 'resource://gre/modules/Services.jsm',
 });

 Services.obs.addObserver(doc => {

RDFDataSource.jsm

 var EXPORTED_SYMBOLS = ["RDFLiteral", "RDFBlankNode", "RDFResource", "RDFDataSource"];

 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;

 XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser", "Element", "fetch"]);

-ChromeUtils.defineModuleGetter(this, "Services",
-                               "resource://gre/modules/Services.jsm");
-
 function isElement(obj) {
   return Element.isInstance(obj);
 }

userChrome.jsm

 let EXPORTED_SYMBOLS = [];

-const { Services } = ChromeUtils.import('resource://gre/modules/Services.jsm');
+const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
 const { xPref } = ChromeUtils.import('chrome://userchromejs/content/xPref.jsm');
 const { Management } = ChromeUtils.import('resource://gre/modules/Extension.jsm');
 const { AppConstants } = ChromeUtils.import('resource://gre/modules/AppConstants.jsm');

xPref.jsm

 let EXPORTED_SYMBOLS = ['xPref'];

-const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');
+const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;

 var xPref = {
   // Retorna o valor da preferência, seja qual for o tipo, mas não
GreatestFool commented 11 months ago

Possibly, at least if you want to keep using scripts that XiaoXiaoFlood has made. Alternatively, there's other loaders out there, like Alice's and MrOtherGuy's loaders, that do have recent commits. Though XiaoXiaoFlood's scripts will need to be modified to function properly with those. Userchrome.org is pretty useful for a small place for general Firefox modification information, if that's of interest.

jathek commented 11 months ago

Thus, I don't think this modification is necessary. Don't know though. Have you tried using it without this change, but keeping the other ones for Services that you've made?

If you try loading resource://gre/modules/Timer.jsm or the other files in Firefox 117, the file is no longer available, so I assumed the change was necessary. I don't know for sure though, someone more knowledgeable would have to confirm.

sujeet commented 11 months ago

@onemen @sdavidg Thanks so much for the fixes! ❤️

Can you share your brief debugging process? Specifically, how did you figure out that the problem was in importing the services? Did you look at FF release notes / changelogs to figure this out? Or, did you look at some logs and those logs had the import errors? If so, can you share where these logs are?

Apologies as these might be super-obvious questions, but I just couldn't figure it out 🥺

sdavidg commented 11 months ago

@onemen found the main bug in userChrome.jsm

To fix the scripts, I use the console CTRL+SHIFT+ALT+I This console shows the errors of the scripts that are being executed, and you can also directly run the code you need to test

For example, if you load passwordManager.xhtml, the console shows the following

imagen

jiangzhenjerry commented 11 months ago

@onemen @sdavidg The fix is broken again in today's nightly build (Aug 11). DTA is enabled but doesn't show up in context menus.

mzso commented 10 months ago

So, to be clear, things only started to break yet again in ff117? Everything was fine in 116? Rather annoying that both the loader and the extensions broke.

MelchiorGaspar commented 10 months ago

Has anyone filed a bug report or complained to Mozilla to stop breaking Firefox?

Cynosphere commented 10 months ago

Has anyone filed a bug report or complained to Mozilla to stop breaking Firefox?

Why would they care, they're just doing the things they need to. They do not owe us modders anything.

You must be new to any modding scene ever.

MelchiorGaspar commented 10 months ago

new? lol no, not too new... been using this extension loader to use TabMixPlus again.. one of my favorite adons.. because Mozilla scrapped there XUL extension system in favor of the inferior Web-Extension API... They alienated most of there advanced user base when they did that.

I have been using Firefox since the early days since v2 or v4 I think,, and extensions since the whenever they first started... :D

Cynosphere commented 10 months ago

Yeah you might not be new to using Firefox, but you clearly know nothing about modding and the intentional lack of support companies are willing to give to modders and mod users because its not something they can support other than whatever first party support exists if any.

You'll just have your (false) "bug" report instantly closed or your emails ignored if you even try. It's up to us to fix it, and fix it I did. I just don't know for sure why my method doesn't work for anyone else.

There's plenty of suggestions in this thread to try.

mzso commented 10 months ago

Seeing all the breakage, I upgraded to only ff116, from FF109. Only DTA seems to broken, and some CSS. Anything can be done for DTA to function? Found an updated version in another issue.

mzso commented 10 months ago

@Cynosphere commented on Aug 2, 2023, 1:13 AM GMT+2:

Readding cmanifest.append("chrome.manifest"); and splitting Cu.import("chrome://userchromejs/content/BootstrapLoader.jsm"); into its own try catch block fixed it somehow.

Legacy extensions need to be manually re-enabled via extensions list userscript; but most will need fixing, along with userscripts that import Services or what not.

Originally posted by @Cynosphere in https://github.com/xiaoxiaoflood/firefox-scripts/issues/265#issuecomment-1661225927

Where can I find the extensions list userscript? I only have an extensions options menu script.

Cynosphere commented 10 months ago

Where can I find the extensions list userscript? I only have an extensions options menu script.

That's the one. Just right click the legacy extension thats disabled to re-enable it.

mzso commented 10 months ago

@Cynosphere If only I knew when I had bunch of them permanently disabled.

zakius commented 10 months ago

Has anyone filed a bug report or complained to Mozilla to stop breaking Firefox?

Why would they care, they're just doing the things they need to. They do not owe us modders anything.

You must be new to any modding scene ever.

it's their fault we have to resort to hacks though, and they repeatedly promised everything will be fine so... there are still some people at Mozilla that actually care but they need help proving some features are important

AlexVallat commented 10 months ago

Yes, people used to complain all the time, and Mozilla realised they had a problem with breaking addons with updates. Too many addons, hooking into any and every part of Firefox internals, meant that eventually they could not update anything without a good chance of it breaking some addon. Their solution to this was WebExtensions. This freed them to make breaking changes to internals without worrying about breaking addons, as the WebExtension API would remain unchanged.

Luckily for us they didn't make it completely impossible to still use full addons, just difficult. The unwritten agreement is, you can still use these, but Mozilla will make no effort not to break them and it's up to you to fix up compatibility whenever necessary. If you want to make addons which Mozilla supports with compatibility in future releases, make WebExtensions.

Of course the other side of the coin was that they were supposed to enhance the WebExtensions API with the functionality that people requested for their addons, but that has sadly mostly not happened.

zakius commented 10 months ago

they were supposed to make all the most important extensions at the very least possible with WE before flipping the kill switch (or in the next few releases at worst) and yet Tab Mix Plus, Fire Gestures, Dorando, DTA and few others providing core features that should've been supported natively in the first place still can't be made with WE

there was a clear paradigm shift and misleading communication

MelchiorGaspar commented 10 months ago

the opening post of this issue ticket worked!. I modified my jsm files in the chrome\util folder and it worked! used the installer method after upgrading my util folder.

Vallek commented 10 months ago

Not working for me(( Tried new files. Tried clear startup cache folder, with button and with -purgecaches. Addon not even appearing in addons page. Came here from tabmix plus, can't imagine using Firefox without it.

UPD Turns out 117 turned 'extensions.experiments.enabled' option in config off! Now everything is working.

mozo78 commented 10 months ago

Hello, my statusbar doesn't working even with the new changes from the first post. May be I make it wrong somewhere. Could domeone send the edited files?

onemen commented 10 months ago

@mozo78,

which extensions, scripts are you using for the statusbar?

mozo78 commented 10 months ago

I don't know. I copied the files as it's shown on the wiki and it worked. I have statusbar for one or two years (I'm not sure but it has been a long time since I'm using it). Now it disappeared. How can I check which scripts I'm using? Should a screenshot do the trick?

Thank you very much for your answer!

onemen commented 10 months ago

@mozo78, scripts are located in your profile chrome folder. list your extensions and scripts

mozo78 commented 10 months ago

As far as I can see, there aren't any scripts: Screenshot_20230901_185903 May be I have to mention that I'm on Linux if this matters.

mozo78 commented 10 months ago

Here's the content of my files: BootstrapLoader.jsm: https://pastebin.com/vRHjxzB7 RDFDataSource.jsm: https://pastebin.com/GDzLr0fq userChrome.jsm: https://pastebin.com/qipx7kqa xPref.jsm: https://pastebin.com/BeCKLq4j

Do you see any errors? Are they edited correctly?

onemen commented 10 months ago

@mozo78

all the files that ends with .uc.js are scripts. probably the file status-bar.uc.js is the script for shewing the statusbar

mozo78 commented 10 months ago

Ok, here it's contents: https://pastebin.com/RGGgefRu I never edited it. it's the original file from here :)

onemen commented 10 months ago

@mozo78, download the script from here

mozo78 commented 10 months ago

Unfortunately it doesn't work. I cleared the startup cache but it doesn't help :(

GreatestFool commented 10 months ago

As far as I can see, there aren't any scripts: Screenshot_20230901_185903 May be I have to mention that I'm on Linux if this matters.

Your folder structure is wrong. The root chrome directory should not contain .jsm files. You have files unrelated to this bootloader there, and I can only assume that you've used another in the past. When you're dealing with these kinds of things, make sure you've properly removed the offending files from previous bootloaders if you've switched to a new one.

At this point, I think it's better that you simply go through and remove all bootloader files, which includes the utils folder's bootloader files, and install xiaoxiaoflood's bootloader again afterwards. Do remember that unless you download a pre-modified zip from this thread, you must change them manually for them to function similarly to before.

mozo78 commented 10 months ago

Oh, yes, it's working again, thank you so much!!!

metronidazole commented 10 months ago

extensions.experiments.enabled

That fixed this for me.

How did you figure that out? It's not documented anywhere.

Vallek commented 10 months ago

How did you figure that out? It's not documented anywhere.

I was googling how to "install unsigned addons" or something like that and saw this option somewhere together with "xpinstall.signature.required". The xpinstall option is locked now so I tried the other one and it worked)

Crunchbits commented 10 months ago

Has anyone been able to fix Download Manager (S3)?

onemen commented 10 months ago

Has anyone been able to fix Download Manager (S3)?

HERE

Crunchbits commented 10 months ago

Has anyone been able to fix Download Manager (S3)?

HERE

If that is also a fix for Download Manager (S3), I don't know what I'm supposed to edit? Looking at Download Manager (S3)'s utils.js it does not seem to use the same module as in DTA. Additionally none of the files that it has seem to use PluralForm. So I do not know what the fix would look like.

onemen commented 10 months ago

@Crunchbits,

sorry

megamorphg commented 10 months ago

@onemen can you edit your 1st post with the full current steps? I did the next upgrade in 117 main release and it broke again. I updated utils based on the package in this comment and then config.js and restarted and scripts broken still.

marty60 commented 10 months ago

I updated utils based on the package in this comment and then config.js and restarted and scripts broken still.

The editing of config.js could be the problem. Try putting that back the way it was previously and only update the files in the utils folder.

megamorphg commented 10 months ago

@marty60 Yes I tried the config.js that gets over-written as:

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

try {
  const 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);

  // signing bypass by Dumby from forum.mozilla-russia.org
  const g = Cu.getGlobalForObject(Cu);
  const sandbox = new Cu.Sandbox(g, { freshCompartment: true });
  Cc['@mozilla.org/jsdebugger;1'].createInstance(Ci.IJSDebugger).addClass(sandbox);
  const dbg = new sandbox.Debugger();
  dbg.addDebuggee(g);
  const gref = dbg.makeGlobalObjectReference(g);

  dbg.onEnterFrame = frame => {
    const { script } = frame;

    if (!script.url.startsWith('resource://gre/modules/AppConstants.'))
      return;

    dbg.onEnterFrame = undefined;

    if (script.isModule) { // ESM, Fx 108+
      const env = frame.environment;
      frame.onPop = () => env.setVariable('AppConstants', gref.makeDebuggeeValue(Object.freeze(
        Object.assign(new Object(), env.getVariable('AppConstants').unsafeDereference(), {
          'MOZ_REQUIRE_SIGNING': false
        })
      )));
    } else { // JSM
      const nsvo = frame.this.unsafeDereference();
      nsvo.Object = {
        freeze (ac) {
          ac.MOZ_REQUIRE_SIGNING = false;
          delete nsvo.Object;
          return Object.freeze(ac);
        }
      };
    }
  }

  ChromeUtils.import('resource://gre/modules/addons/XPIInstall.jsm');

  dbg.removeAllDebuggees();

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

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

And also the one in this main repository. Also tried rebuilding repository after each attempt. The other program files looked the same as repository.

marty60 commented 10 months ago

@megamorphg,

That's the same one I'm using by Dumby and it works fine for me, the only difference is I have this extra line on top:

lockPref("extensions.experiments.enabled", true);

If it's still broke with this config.js file and the utils folder with the updated files inside the Chrome folder then it's possible your scripts need updating. I had to edit a few of those myself even with these changes. It was just a simple matter of removing a services line. You can post one of the scripts or zip it so someone can take a look at it.

onemen commented 10 months ago

I am using this config.js

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

try {
  const 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);

  const objRef = ChromeUtils.import('resource://gre/modules/addons/XPIDatabase.jsm');
  objRef.XPIDatabase.SIGNED_TYPES.delete("extension");

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

try {
  Cu.import('chrome://userchromejs/content/userChrome.jsm');
} catch (ex) {};
megamorphg commented 10 months ago

@onemen @marty60 I've tried both your scripts on the latest 117 on Release channel and it still doesn't work.

  1. replace config.js with what you've posted
  2. replace the chrome utils files
  3. start FF

None of the scripts load. I'm only using the following scripts and extensions (all from the main repository except Animancer's which worked too): image

marty60 commented 10 months ago

@megamorphg,

Just want to check all the bases, you also have the config-prefs.js file in the prefs folder?

If you go to Menu Bar/Tools is the userChromeJS Manager there and if so all of the scripts checked to run? Or alternately if you have the button on the Navigation bar.

megamorphg commented 10 months ago

@marty60 so I needed to refresh the startup via about:support (and not by deleting addonstartup)... and then all my scripts started working! Addons are still disabled... any idea on how to re-enable that for Release? I tried "update addons" and it didn't work like last time. Otherwise I'll have to find the right add-on ID for all disabled extensions in my 3 browsers and run JS as instructed in #264...

onemen commented 10 months ago

Read this

rebmcr commented 10 months ago

splitting Cu.import("chrome://userchromejs/content/BootstrapLoader.jsm"); into its own try catch block fixed it somehow.

This is what worked for me too — I never had a BootstrapLoader.jsm in the first place.

117649 commented 10 months ago

@marty60 so I needed to refresh the startup via about:support (and not by deleting addonstartup)... and then all my scripts started working! Addons are still disabled... any idea on how to re-enable that for Release? I tried "update addons" and it didn't work like last time. Otherwise I'll have to find the right add-on ID for all disabled extensions in my 3 browsers and run JS as instructed in #264...

If you know how to use f12 you can use that on about:addons to reveal the hidden enable switch. Flip it back and forth one or more times should kick start the addon if you have all scripts in function.

GreatestFool commented 10 months ago

@megamorphg, I see you've mentioned that you're using "release" and the "Release channel" a few times. Do note that advanced modification using userscripts in the chrome directory requires that you use Firefox Developer Edition. Or the aurora release channel, if you want to reference what it says in the about section of the browser. Bootloaders like this one will not work on the release channel, the regular Firefox.

117649 commented 10 months ago

@megamorphg, I see you've mentioned that you're using "release" and the "Release channel" a few times. Do note that advanced modification using userscripts in the chrome directory requires that you use Firefox Developer Edition. Or the aurora release channel, if you want to reference what it says in the about section of the browser. Bootloaders like this one will not work on the release channel, the regular Firefox.

NO, it not.