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

Firemonkey: 4chan-x incompatibility? #408

Closed
g-2-s opened this issue Jan 14, 2022 · 10 comments
Closed

Firemonkey: 4chan-x incompatibility? #408

g-2-s opened this issue Jan 14, 2022 · 10 comments
Labels
addon: FireMonkey userscript: compatibility userScript/userCSS Compatibility

Comments

@g-2-s
Copy link

g-2-s commented Jan 14, 2022

Hi. Here's the issue I'm experiencing: 4chan-x doesn't keep your settings, if you reload the page, open a thread or navigate to another board, it reverts to default and it always shows the splash screen for the settings panel like it's the first time you're using the script. What could the cause be? I seem to recall that the script used to work with Firemonkey some years ago but now it's unusable.

@erosman
Copy link
Owner

erosman commented Jan 14, 2022

To start with, 4chan-X.user.js is a massive script, 1.1mb & 28,357 lines. It would only be practical for developers to debug it.

Some suggestions:

  • Use of @match instead of @include is a lot more robust and recommenced by all userscript managers
    For example:
// @include      http://boards.4chan.org/*
// @include      https://boards.4chan.org/*

It would be better to use:

// @match      *://boards.4chan.org/*
  • There are many @connect and then there is a @connect * which means everything so the others are not needed.

Above are only suggestions and not the cause of the incompatibility.

Possible Cause

The possible cause of keeping/saving settings is the use of setValue/getValue.

The script supports both synchronous GM_getValue/GM_setValue and asynchronous GM.getValue/GM.setValue.

  • Greasemonkey only supports asynchronous GM.getValue/GM.setValue
  • Violentmonkey support both but in a synchronous manner
  • Tampermonkey support both but in a synchronous manner
  • FireMonkey support both but GM_getValue/GM_setValue in an partial synchronous manner, and GM.getValue/GM.setValue in an asynchronous manner

Since the script is supported in asynchronous GM, it should also work in FireMonkey. However, the way script checks the supported APIs, causes issues on FM.

  • Line 5277 checks for GM.openInTab first, so it should be fine on FM
  • Line 5448 checks for GM.deleteValue first, so it should be fine on FM, however the next check is GM_addValueChangeListener (not supported by GM therefore, the script attempts the synchronous GM_deleteValue & GM_getValue on line 5542 which can be an issue on FM
  • Line 5566 Same as above
  • .... etc

Personally, I would test the supported API once at the start of the script and then use that value for the entire script.
e.g. instead of

if (!(((typeof GM !== "undefined" && GM !== null ? GM.xmlHttpRequest : void 0) != null) || (typeof GM_xmlhttpRequest !== "undefined" && GM_xmlhttpRequest !== null))) {
...

I would ...

// check the supported asynchronous/synchronous API
const asyncGM = typeof GM === 'object' && !!GM.info;

Then use asyncGM to test everywhere else.

Solution

  • If script developers are willing, I can make a few suggestions that should help with making the script compatible with all userscript managers
  • I can add a user setting to FORCE the use of asynchronous API for userscripts that support both

📌 I am going to add the feature anyway. It will be there for the next upgrade.

@g-2-s
Copy link
Author

g-2-s commented Jan 14, 2022

Yeah, I opened an issue exactly 1 year ago on the 4chan-x repo but never got a reply, so I think it's safe to assume the dev is not going to bother with compatibility with other userscript managers. If you can manage to update Firemonkey so that the script can work as intended (which it does actually, it only doesn't save your prefs), I'll forever be grateful and hopefully some other anons will too.

@erosman
Copy link
Owner

erosman commented Jan 14, 2022

@disable-synchGM added to User Metadata in v2.41
It will remove all GM_* API support so userscripts that use both types will be forced to use GM.* API.

If you can manage to update Firemonkey so that the script can work as intended

If the problem is the sync/async checks, and the userscript work fine on Greasemonkey, then hopefully that will solve the issue. Let's see.

Note: I have added support for containers (#378) in v2.41

  • Container in userCSS is done for Firefox 97 in Bug 1470651
  • Container in userScript is not done yet in Bug 1738567

I am waiting for above to release v2.41

@erosman
Copy link
Owner

erosman commented Jan 18, 2022

v2.41 uploaded

Try @disable-synchGM in User Metadata and see if that helps

@erosman erosman closed this as completed Jan 19, 2022
@g-2-s
Copy link
Author

g-2-s commented Jan 20, 2022

Hi sorry for the late reply but 2.41 + @disable-synchGM now make the script finally save your prefs, thank you very much for this!

@erosman erosman added the userscript: compatibility userScript/userCSS Compatibility label Jan 27, 2022
@erosman
Copy link
Owner

erosman commented Jan 29, 2022

Also in v2.42
Added experimental background @grant processing to disable sync GM API if both sync/async GM API are supported

@erosman
Copy link
Owner

erosman commented Jan 31, 2022

Above feature may make the @disable-synchGM obsolete 🤔

@erosman
Copy link
Owner

erosman commented Sep 27, 2022

re: #507

@g-2-s Are you having issues with 4chan-x?

@g-2-s
Copy link
Author

g-2-s commented Sep 27, 2022

re: #507

@g-2-s Are you having issues with 4chan-x?

Yeah, unfortunately the 4chan-x script doesn't work at all with Firemonkey.

@qwertea
Copy link

qwertea commented Sep 12, 2023

The script doesn't work at all unless I manually "run" it from the FireMonkey popup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: FireMonkey userscript: compatibility userScript/userCSS Compatibility
Projects
None yet
Development

No branches or pull requests

3 participants