xiaoxiaoflood / firefox-scripts

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

Preparation for Firefox 117 #265

Open onemen opened 12 months ago

onemen commented 12 months 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
117649 commented 12 months ago

@onemen @xiaoxiaoflood is lost contact for so long may be consider put all these in a fork?

onemen commented 12 months ago

maybe @xiaoxiaoflood can update us about what are the plans for this repository

Aleksandra0056 commented 12 months ago

Last commit by xiaoxiaoflood was made on February 25, 2023 (4.5 months ago), so it is unlikely, that he will make any change.

117649 commented 12 months ago

maybe @xiaoxiaoflood can update us about what are the plans for this repository

Last commit by xiaoxiaoflood was made on February 25, 2023 (4.5 months ago), so it is unlikely, that he will make any change.

Make a pr so if @xiaoxiaoflood showed up again he can accept it?

Aleksandra0056 commented 12 months ago

I don't know what happened to xiaoxiaoflood, but maybe he lost his password, or maybe someone hacked him account, or maybe he had an accident.

If one of these theories are true, then he didn't show up again, but onemen should decide what to do, if he forks this repository or if he makes a Pull Request.

Aleksandra0056 commented 12 months ago

And only extensions stop work? Or also scripts (like status bar, or extensions options menu) stop work from Firefox 117.0?

megamorphg commented 12 months ago

Yeah, he used to respond fairly quickly. I honestly use only a couple of the add-ons. I'm wondering if I just uninstall this... it's just too complicated to maintain this on top of all the other FF customizations.

Does FF 117 automatically make things go back to default or do I have to do anything else? I might just leave it be and remove the addons and scripts if it doesn't break anything to do so.

Aleksandra0056 commented 12 months ago

So, I think, that forking this repository would be the best idea if xiaoxiaoflood is not responding. If I'll update to Firefox 117.0 then I will change my JS files in chrome directory to use actual code as onemen wrote, other people should do the same.

marty60 commented 12 months ago

Thanks for this, it probably explains why I'm suddenly having context menu problems with DTA in 117.

xiaoxiaoflood is still around, he posts at Reddit as tustamido:

https://old.reddit.com/user/tustamido

onemen commented 12 months ago

Firefox 117 is now on Nightly, until it reach production we will figure out what to do.

117649 commented 12 months ago

Thanks for this, it probably explains why I'm suddenly having context menu problems with DTA in 117.

xiaoxiaoflood is still around, he posts at Reddit as tustamido:

https://old.reddit.com/user/tustamido

Hoping you're not mismatching accounts of different person.

marty60 commented 12 months ago

Hoping you're not mismatching accounts of different person.

This is the thread I got the name from:

https://old.reddit.com/r/XUL_for_Quantum_Dev/comments/fs76ff/little_update_current_fx_version_75/

marty60 commented 12 months ago

This whole thing is a mess now. Removing that one line from config.js breaks the custom buttons addon so I can't do anything with that since CB is a must have.

Even with all of the changes the two scripts I have still don't work and that's probably due to updates that need to be made with the scripts.

In addition, keyconfig and DTA are dead, also must haves. Might as well stay with an earlier nightly for the time being until everything can be sorted out. Hopefully xiaoxiaoflood returns since he's usually been good with this project.

onemen commented 12 months ago

@marty60,

you probably need to fix +const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services for all scripts that use Services

marty60 commented 12 months ago

you probably need to fix +const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services for all scripts that use Services

Thanks for that but tried and still didn't work. It's a script by Aris that makes the forward button moveable so I can visit him and he'll probably give me an update.

marty60 commented 11 months ago

Yesterday seemed dire but today's nightly everything returned except for keyconfig. DTA is still functional. I was able to fix Aris's script by simply removing this line:

var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});

The only caveat is if I delete the line from config.js everything breaks so keeping it in seems to be the fix, at least for me since custom buttons apparently needs it and it's not breaking the scripts.

Any chance at taking a look at keyconfig? I don't know about any of the other extensions.

marty60 commented 11 months ago

For anyone using Password Manager open passwordManager.js with Wordpad and delete these lines:

/ eslint-disable-next-line no-var / var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

marty60 commented 11 months ago

Getting keyconfig to work again was actually pretty easy. You just need to go through these files and delete these lines:

Bootstrap.js: Components.utils.import("resource://gre/modules/Services.jsm");

defaultPreferencesLoader.jsm: const { utils: Cu, classes: Cc, interfaces: Ci } = Components; Cu.import('resource://gre/modules/Services.jsm');

edit.xhtml: var {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');

Keyconfig.js: var {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');

ChromeManifest.jsm: Components.utils.import("resource://gre/modules/Services.jsm");

Overlays.jsm: ChromeUtils.defineModuleGetter( this, "Services", "resource://gre/modules/Services.jsm" );

If you start Firefox and it’s not showing in Tools going into about:addons disabling then re-enabling it should bring it back. Might have to reboot it a few times and clean out the error log.

Aleksandra0056 commented 11 months ago

What is keyconfig?

marty60 commented 11 months ago

What is keyconfig?

It's one of xiaoxiaoflood's revised addons:

https://github.com/xiaoxiaoflood/firefox-scripts/tree/master/extensions

It's been around forever, it was originally developed by dorando and let's you easily re-map keyboard shortcuts. It's been a must have for me since the firefox 3.6 days.

benzBrake commented 11 months ago

What is keyconfig?

It's one of xiaoxiaoflood's revised addons:

master/extensions

It's been around forever, it was originally developed by dorando and let's you easily re-map keyboard shortcuts. It's been a must have for me since the firefox 3.6 days.

You can try this script for temporary usage

Aleksandra0056 commented 11 months ago

Yesterday seemed dire but today's nightly everything returned except for keyconfig.

@marty60 What returned? You mean, that extensions are working again? Or also scripts are working again? You wrote it unclearly.

marty60 commented 11 months ago

@marty60 What returned? You mean, that extensions are working again? Or also scripts are working again? You wrote it unclearly.

After making the changes to the files in the utils folder that onemen posted but leaving that line in config.js the scripts are working (I had to manually fix one of them). DTA is also working. Keyconfig had to be manually updated, the changes to the files were posted above.

At least for me, everything is back to normal. If you're having a problem with any scripts or addons post it and maybe someone can help.

marty60 commented 11 months ago

You can try this script for temporary usage

@benzBrake I've got keyconfig updated to load again in 117.0 but how does your script work? I tried using it but am getting an error. If it does what keyconfig can it would make a useful backup.

benzBrake commented 11 months ago

You can try this script for temporary usage

@benzBrake I've got keyconfig updated to load again in 117.0 but how does your script work? I tried using it but am getting an error. If it does what keyconfig can it would make a useful backup.

I have add a English Version of Readme. What's the error message?

Aleksandra0056 commented 11 months ago

So, someone should contact xiaoxiaoflood here https://www.reddit.com/user/tustamido if it is his reddit account.

marty60 commented 11 months ago

I have add a English Version of Readme. What's the error message?

Actually getting two error messages, one at startup and then another load error after clicking that. It's also generating a file in userChrome called _keychanger.js.

What exactly does this script do and how does it work? Does it do the same thing as keyconfig?

load error.zip

benzBrake commented 11 months ago

I have add a English Version of Readme. What's the error message?

Actually getting two error messages, one at startup and then another load error after clicking that. It's also generating a file in userChrome called _keychanger.js.

What exactly does this script do and how does it work? Does it do the same thing as keyconfig?

load error.zip

The first message is to let you click and then automatically create a configuration file _keychanger.js. The second message is that the configuration file is empty.

Here is a reference configuration file: https://github.com/benzBrake/FirefoxCustomize/blob/master/userChromeJS/KeyChanger/_keychanger.js

marty60 commented 11 months ago

Ok I see how it works and this is why Firefox is the best browser hands down. I was able to get everyone of the keyconfig codes and re-mapping I use in the addon with your script. Nice job.

_keychanger.zip

rosgr100 commented 11 months ago

Any chance for someone to upload a zip with the needed edited files?

Thank you.

marty60 commented 11 months ago

Any chance for someone to upload a zip with the needed edited files?

Thank you.

utils.zip

rosgr100 commented 11 months ago

Thank you @marty60!

sdavidg commented 11 months ago

@onemen Where do you get a version 117 that userChromeJS can run on?

I download versions from here https://treeherder.mozilla.org/jobs?repo=mozilla-beta&resultStatus=success%2Crunnable&searchStr=addon

onemen commented 11 months ago

https://www.mozilla.org/en-US/firefox/all/#product-desktop-release

sdavidg commented 11 months ago

https://www.mozilla.org/en-US/firefox/all/#product-desktop-release

Thanks @onemen , but that version don't support firefox-scripts

onemen commented 11 months ago

I am using firefox nightly 117 with firefox-scripts every day

sdavidg commented 11 months ago

I must be doing something wrong. I have never been able to use the normal builds of firefox, only the unbranded builds: https://wiki.mozilla.org/Add-ons/Extension_Signing#Unbranded_Builds

Cynosphere commented 11 months ago

117 has hit Developer Edition, but fixes don't work

Could not read chrome manifest 'file:///C:/Users/<>/AppData/Roaming/Mozilla/Firefox/Profiles/<>.dev-edition-default/chrome/utils'.
No chrome package registered for chrome://userchromejs/content/BootstrapLoader.jsm
No chrome package registered for chrome://userchromejs/content/userChrome.jsm
Cynosphere commented 11 months ago

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.

dsyo2008 commented 11 months ago

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.

You can test it, but I tried it and it still doesn't work, how do I do it?

GreatestFool commented 11 months ago

So, I've been using a script for a custom MacOS-esque scrollbar for quite some time and it's also broken after updating to 117. I've modified the required files, so I do get it to load, however it's not rendering when it does. I've tried adding const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services; within the function, as well as simply commenting out the sections that require it, but I still can't actually get it to render. I do get the scrollbars to disappear though, so there's that. Strangely, if I modify the namespace url, like removing the space or adding quotes around it, the scrollbar breaks and the default one renders instead.

I suspect it may be the CSS being weird, but I simply don't know enough about Firefox's internals to see what's wrong. This is the modified file I currently have. I've tried other things, like adding this userChrome.xml, but I'm pretty stumped.

Does anyone know what's wrong with it, or where I can look for information on how to fix it?

hgdagon commented 11 months ago

Did you guys do anything specific to make DTA work again? I'm on 117.0b2 Dev Edition, just made these changes in my utils folder, but DTA is still not functional. I still see DTA in the addons list. but it is not in my Tools menu, nor the context menu, and the download file dialog is messed up (I only see "open with" and "save file" options but the radio buttons are missing). I also cannot see any of scripts. Did I skip a step or something?

Update: I noticed config-prefs.js was moved to defaults/pref, but not config.js, so I just moved it there, reinstalled DTA, and restarted Firefox. DTA is back now. So are the scripts. I still don't see the radio buttons on the Save file dialog. It seems like they're there, but dark like the background. Seems like the same issue we had on one the older versions of DTA.

GreatestFool commented 11 months ago

Update: I noticed config-prefs.js was moved to defaults/pref, but not config.js, so I just moved it there

config.js should remain in the root of the Firefox installation directory, as far as I know. I'm surprised it even half works, though I suppose so long as Firefox loads any JS file from that directory, it'll work, since it's not doing anything with hardcoded filesystem paths.

Regardless, a few scripts will need to be manually edited for them to work. E.g. XiaoXiaoFlood's Styloaix script needs to have the edit.js file edited to include const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services; in the function, otherwise it won't load files or be able to save them.

I can't really say what did or didn't make DTA work, since I don't use it, but if you didn't clear the startup cache in about:support, that may have been part of the issue. Playing around with the bootloader almost necessitates flushing it.

jathek commented 11 months ago

anyone know how to fix the LinkStatusRedux extension? I replaced the Chrome Services import I found that was similar to above, but there are a couple of Component lines in two files. And there are other resource://gre/modules.... imports that I think need to be replaced. I attempted to fix those but don't know if I did it right.

./bootstrap.js - ???????

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

./chrome/content/ChromeManifest.jsm - ???????

this.EXPORTED_SYMBOLS = ["ChromeManifest"];

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

/**
 * A parser for chrome.manifest files. Implements a subset of
 * https://developer.mozilla.org/en-US/docs/Mozilla/Chrome_Registration
 */

./chrome/content/options.js

  set lastSelected(val) {
    this.setAttribute("lastSelected", val);
-    const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');
+    const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
    Services.xulStore.persist(this, "lastSelected");
    return val;
  }

./chrome/content/Overlays.jsm - ???????

this.EXPORTED_SYMBOLS = ["Overlays"];

-const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
+const ConsoleAPI = globalThis.console || ChromeUtils.import("resource://gre/modules/Console.jsm").ConsoleAPI;
-ChromeUtils.defineModuleGetter(
-  this,
-  "Services",
-  "resource://gre/modules/Services.jsm"
-);
+const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
-ChromeUtils.defineModuleGetter(
-  this,
-  "setTimeout",
-  "resource://gre/modules/Timer.jsm"
-);
+const setTimeout = globalThis.setTimeout || ChromeUtils.import("resource://gre/modules/Timer.jsm").setTimeout;

let oconsole = new ConsoleAPI({

After my changes, the options page looks broken, although the extension itself seems to work otherwise. image

Orriky commented 11 months ago

anyone know how to fix the LinkStatusRedux extension? I replaced the Chrome Services imports, but there are a couple of Component lines in two files, like this: Components.utils.import("resource://gre/modules/Services.jsm");

I replaced those but the options page looks broken, although the extension itself seems to work otherwise. image

Hi, Please, can you post your modded LinkStatusRedux? I use bootstrapLoader and all legacy extensions are disabled but bootstrapLoader itself

GreatestFool commented 11 months ago

Any chance for someone to upload a zip with the needed edited files? Thank you.

utils.zip

@jathek: marty60 has linked to a zip of the edited files. You can try to use those to see if it helps, but for modifying scripts, you only need to change the Services part, I think.

./chrome/content/Overlays.jsm - ???????

this.EXPORTED_SYMBOLS = ["Overlays"];

-const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
+const ConsoleAPI = globalThis.console || ChromeUtils.import("resource://gre/modules/Console.jsm").ConsoleAPI;
-ChromeUtils.defineModuleGetter(
-  this,
-  "Services",
-  "resource://gre/modules/Services.jsm"
-);
+const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
-ChromeUtils.defineModuleGetter(
-  this,
-  "setTimeout",
-  "resource://gre/modules/Timer.jsm"
-);
+const setTimeout = globalThis.setTimeout || ChromeUtils.import("resource://gre/modules/Timer.jsm").setTimeout;

let oconsole = new ConsoleAPI({

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?

Orriky commented 11 months ago

@jathek this one work for me https://www.mediafire.com/file/ypkwzz4nnjnjkuv/linkstatusredux_mod.xpi/file maybe you don't have fixed the moz-box issue

The only problem is that I have to refresh addon page to have the extension option entries

LummoxJR commented 11 months ago

Well, I'm on 117b3 now and suddenly none of my userscripts are working at all. I tried making the changes to all the Services lines in the files I have, and no such luck. Is anyone at all having success on 117b3?

I'm at my wit's end trying to figure out what else I need to change. I hadn't updated config.js in a long time so I went with the newest version of that.

Edit: Adding to this, does anyone know how I can get debugging info about why things aren't loading? The multi-process browser console isn't showing me anything related to userscripts, UserChrome.jsm, Services.jsm, and so on. As far as I can tell, it's like none of this is even trying to run at all.

GreatestFool commented 11 months ago

That depends on what kinds of scripts you have, which version of XiaoXiaoFlood's loader you have as well as things like if you've flushed the startup cache in about:support. If nothing at all is loading, I'd say that seems to be a problem with the bootloader. I'd recommend simply reinstalling that part by overwriting the config.js file in Firefox's install directory and also the relevant ones in chrome/utils and then repeating the steps in the op.

LummoxJR commented 11 months ago

Aha! Clearing the startup cache did indeed fix it. I feel stupid now.

So it looks like we're okay for the time being but unless Xiaoxiaoflood returns, someone's probably gonna have to fork this project to keep it updated.