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

Firefox Nightly remove support for JSM - All scripts not working #335

Open
onemen opened this issue Jan 24, 2025 · 20 comments
Open

Firefox Nightly remove support for JSM - All scripts not working #335

onemen opened this issue Jan 24, 2025 · 20 comments

Comments

@onemen
Copy link

onemen commented Jan 24, 2025

Bug 1881888 - Remove support for JSMs landed in Firefox Nightly 136 on 2025-01-25

[userChrome.jsm](https://github.com/xiaoxiaoflood/firefox-scripts/blob/master/chrome/utils
/userChrome.jsm)
hookFunction.jsm
xPref.jsm

stop working

Also config.js need update since ChromeUtils.import was removed

try {
  ChromeUtils.import('chrome://userchromejs/content/userChrome.jsm');
} catch (ex) {};
@onemen
Copy link
Author

onemen commented Jan 24, 2025

 userChrome.jsm => userChrome.js | 12 +++++++-----
 xPref.jsm => xPref.sys.mjs      |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)
 rename userChrome.jsm => userChrome.js (94%)
 rename xPref.jsm => xPref.sys.mjs (94%)

diff --git a/userChrome.jsm b/userChrome.js
similarity index 94%
rename from userChrome.jsm
rename to userChrome.js
index 17a9224..759fb20 100644
--- a/userChrome.jsm
+++ b/userChrome.js
@@ -1,8 +1,10 @@
-let EXPORTED_SYMBOLS = [];
+'use strict';
 
-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');
+ChromeUtils.defineESModuleGetters(this, {
+  xPref: 'chrome://userchromejs/content/xPref.sys.mjs',
+  Management: 'resource://gre/modules/Extension.sys.mjs',
+  AppConstants: 'resource://gre/modules/AppConstants.sys.mjs',
+});
 
 let UC = {
   webExts: new Map(),
@@ -95,7 +97,7 @@ let _uc = {
   },
 
   everLoaded: [],
-  
+
   loadScript: function (script, win) {
     if (!script.regex.test(win.location.href) || (script.filename != this.ALWAYSEXECUTE && !script.isEnabled)) {
       return;
diff --git a/xPref.jsm b/xPref.sys.mjs
similarity index 94%
rename from xPref.jsm
rename to xPref.sys.mjs
index 836b3df..aba56db 100644
--- a/xPref.jsm
+++ b/xPref.sys.mjs
@@ -1,6 +1,6 @@
-let EXPORTED_SYMBOLS = ['xPref'];
+'use strict';
 
-var xPref = {
+export const xPref = {
   // Retorna o valor da preferência, seja qual for o tipo, mas não
   // testei com tipos complexos como nsIFile, não sei como detectar
   // uma preferência assim, na verdade nunca vi uma
--```

@ozzyjr
Copy link

ozzyjr commented Jan 24, 2025

Brasileiro?

+export const xPref = {
// Retorna o valor da preferência, seja qual for o tipo, mas não
// testei com tipos complexos como nsIFile, não sei como detectar
// uma preferência assim, na verdade nunca vi uma
--```

@117649
Copy link

117649 commented Jan 24, 2025

  • xPref: 'chrome://userchromejs/content/xPref.sys.mjs',

@onemen .sys isn't a part of the ESM extensions name but a mark of Firefox system modules.
So you should not want to use it anywhere.
If you want to keep the same format .uc is a go to choice.

@marty60
Copy link

marty60 commented Jan 24, 2025

Any chance someone could upload the updated files?

@kaos-55
Copy link

kaos-55 commented Jan 25, 2025

@marty60

Any chance someone could upload the updated files?

I tried to update the files according to onemen's changes, but I still need to update the config.js file to make it work and I don't know how to do that. Also, even if the autoconfig is fixed, it would be necessary to refactor all the scripts since they removed several functions used by the scripts. Unless someone takes care of updating the scripts since @xiaoxiaoflood is missing, it seems to me that this is the end of the scripts and the repository.

@dimdamin
Copy link

it seems to me that this is the end of the scripts and the repository.

only when that happens.

@onemen
Copy link
Author

onemen commented Jan 25, 2025

@marty60

Any chance someone could upload the updated files?

I tried to update the files according to onemen's changes, but I still need to update the config.js file to make it work and I don't know how to do that. Also, even if the autoconfig is fixed, it would be necessary to refactor all the scripts since they removed several functions used by the scripts. Unless someone takes care of updating the scripts since @xiaoxiaoflood is missing, it seems to me that this is the end of the scripts and the repository.

config.js update:

try {
-  ChromeUtils.import('chrome://userchromejs/content/userChrome.jsm');
+  Services.scriptloader.loadSubScript('chrome://userchromejs/content/userChrome.js'); 
} catch (ex) {};

I will try to create a fork to this repository after i finish to update Tab mix Plus

@marty60
Copy link

marty60 commented Jan 25, 2025

@onemen,

try {

  • ChromeUtils.import('chrome://userchromejs/content/userChrome.jsm');
  • Services.scriptloader.loadSubScript('chrome://userchromejs/content/userChrome.js');
    } catch (ex) {};

Thanks everyone for the response. The config.js was the problem but this fixed it so now I've got it working again. The files have been uploaded.

Unfortunately three of my addons: keyconfig, saved passwords, and dta are broke and will need to be updated as well so still got some work to do.

chrome-utils folder.zip

autoconfig.zip

Fixed browser.newtab.url script:

newtab-aboutconfig.uc.zip

@marty60
Copy link

marty60 commented Jan 25, 2025

it seems to me that this is the end of the scripts and the repository.

only when that happens.

@dimdamin

Where did you see that Mozilla plans to end support for autoconfig?

@dimdamin
Copy link

Where did you see that Mozilla plans to end support for autoconfig?

Stop twisting things around, I asked a question with the hope of getting an answer.

@marty60
Copy link

marty60 commented Jan 26, 2025

Stop twisting things around, I asked a question with the hope of getting an answer.

My apologies if I misunderstood but your posts made it appear as though the removal of autoconfig.js was inevitable. Good to know it isn't.

@sdavidg
Copy link

sdavidg commented Jan 29, 2025

I use this code to save a string into a file:

   	var ostream = Cc['@mozilla.org/network/file-output-stream;1'].createInstance(Ci.nsIFileOutputStream);
   	ostream.init(file, -1, -1, 0);
   	var istream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
   	istream.setUTF8Data(content);
   	NetUtil.asyncCopy(istream, ostream, aCallback)

For "NetUtil" I use this code:

   	const { NetUtil } = ChromeUtils.import('resource://gre/modules/NetUtil.jsm');

but ChromeUtils.import don't work anymore, and 'resource://gre/modules/NetUtil.jsm' don't exist in FF136.

Does anyone have any idea how to resolve this?


OK, resolved:

ChromeUtils.defineESModuleGetters(this, {
   NetUtil: 'resource://gre/modules/NetUtil.sys.mjs'
});

@XeonG
Copy link

XeonG commented Feb 3, 2025

TMP has been updated.. but it seems .css changes I made in UserStyles folder no longer work.. pretty sure that stuff worked with styloaix ...no longer the case?

@onemen
Copy link
Author

onemen commented Feb 3, 2025

TMP has been updated.. but it seems .css changes I made in UserStyles folder no longer work.. pretty sure that stuff worked with styloaix ...no longer the case?

check in about:config that toolkit.legacyUserProfileCustomizations.stylesheets is true

@XeonG
Copy link

XeonG commented Feb 4, 2025

I got it working but it's not working how it used to be.. ie the .css files were in the 'UserStyles' folder that ones styloaix handled I think.. no idea seems a bunch of stuff on this doesn't work still

..css stuff I was using all got chucked into /chrome/userChrome.css and that works.

@marty60
Copy link

marty60 commented Feb 4, 2025

In order for the legacy addons to install and work won't BootstrapLoader.jsm and other files in the utils folder have to be updated? Even when trying to fix addons I'm getting an error that the addon appears corrupt when attempting to install it.

@117649
Copy link

117649 commented Feb 4, 2025

In order for the legacy addons to install and work won't BootstrapLoader.jsm and other files in the utils folder have to be updated? Even when trying to fix addons I'm getting an error that the addon appears corrupt when attempting to install it.

They were done. BootstrapLoader.jsm isn't a module script in fact.

@Aleksandra0056
Copy link

Aleksandra0056 commented Mar 4, 2025

How can I fix this issue entirely? I can't run any of my scripts. Can someone develop the damn fix for all files? It's the year 2025 and not 1930. Technological sufficiency should be enough for a universal fix for all files to be developable for these simple programs/apps.

I can't find any updated files in the comments (except those in chrome-utils.folder.zip).

Firefox Scripts is constantly breaking. CustomJSforFx has not working at all since update 136.0.

By the way, what is happening to humanity? Everything has been breaking in the last decade. Even I was frustrated today because my PC is constantly suddenly shutting down, and restarting it isn't working. My laptop completely broke. My sound tuner broke.

The entire world is upside down. I apologise for speaking off-topic, but it's truth.

@marty60
Copy link

marty60 commented Mar 4, 2025

@Aleksandra0056,

If you've updated the chrome-utils.folder and config.js from here:

#343

then from about:config try toggling "security.browser_xhtml_csp.enabled" to false. If the only update needed for the script is event handlers then it should work again in 136+.

As has been posted several times it's only a temporary fix as Mozilla plans to remove that pref in the future but it will buy some time until the scripts can be properly updated.

@Aleksandra0056
Copy link

@Aleksandra0056,

If you've updated the chrome-utils.folder and config.js from here:

#343

then from about:config try toggling "security.browser_xhtml_csp.enabled" to false. If the only update needed for the script is event handlers then it should work again in 136+.

As has been posted several times it's only a temporary fix as Mozilla plans to remove that pref in the future but it will buy some time until the scripts can be properly updated.

Thank you, and I wish you all good luck with the development of fixes. It's true, that Mozilla leadership is turning authoritarian, but I believe, that Firefox is still better than Chrome.

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

9 participants