TuxedoTako / 4chan-xt

Adds various features to anonymous imageboards.
Other
134 stars 9 forks source link

Support for MV3? #83

Open saxamaphone69 opened 4 months ago

saxamaphone69 commented 4 months ago

In line with another round of discussions about uBlock that popped up recently, and also the same conversations you'll find within userstyle and userscript managers on GitHub, Chrome's forcing of MV3 could potentially makes things a little more annoying to manage in the future. This is an X and XT issue, and a "mainstream" Chrome (and maybe Edge/Opera?) issue. Some de-Googled Chrome forks appear to be still supporting MV2, as will Firefox.

image

I'd imagine that some of the issues would be when 4chan XT inserts itself, how it inserts itself, and things like archives.json might not be able to auto-update (instead, a new release would be required if a change is made - this is based on the idea that filters in uBlock wouldn't be able to auto-update, but that might be different to what XT does) or stuff to do with fetching information. Alternatively, switching might be straight forward.

Also, while checking the crx build, this error appears but I don't think it actually impacts anything.

image

Either way, not exactly an issue right now, but one that would eventually happen in the coming months. Or, pushed back once again like this time last year given the pushback.

TuxedoTako commented 3 months ago

Looks like it won't be as easy as just updating the manifest.

image

Looks like MV3 doesn't allow injecting scripts in the main thread, which is needed for the captcha in the custom quick reply, among a few other things. Looks like the ajax function needs to be changed too, since we can't use the event page anymore.

TuxedoTako commented 3 months ago

Update: looks like it's possible to inject code in the main thread, just not from the user script, it has to be done from the service worker, basically eventPage.js. It's just some tedious work extracting those functions to load them in the eventPage.js context instead of the main script. No I can't move the full script to the service worker, since that context doesn't have DOM access.

Which makes me wonder how the userscript version will do it from a mv3 userscript manager. The userscript is my perfered way, since the extension doesn't auto update.

TuxedoTako commented 3 months ago

Great, seems manifest V3 for chrome and firefox are mutually exclusive: https://github.com/mozilla/web-ext/issues/2532. Chrome needs the background script to be in background.service_worker, and firefox doesn't support that, but supports background.scripts. I think I'll keep releasing a manifest v2 version for firefox, and a v3 for chrome that complains about v2.

The good news is that it seems I didn't have to remove functionality. I need to finish up the build script to build the userscript, mv2 and mv3, but you can try this one now: crx chrome mv3.zip. Code is on the mv3 branch.

TuxedoTako commented 3 months ago

2.13.0 has a manifest V3 available, so we're future proof.