anka-213 / webcomic_reader

Webcomic Reader userscript at
https://openuserjs.org/scripts/anka-213/Webcomic_Reader
MIT License
120 stars 27 forks source link

Migrate “GM_*” calls to Greasemonkey 4’s “GM.*” API #130

Open roryokane opened 5 years ago

roryokane commented 5 years ago

See Greasespot: Greasemonkey 4 For Script Authors.

Greasemonkey 4 introduced new APIs for the functionality provided by GM_ functions. As the blog post says, these APIs will eventually be faster than the old APIs. The new APIs also have clearer names and better organization.

Currently, this script uses these GM_ functions:

https://github.com/anka-213/webcomic_reader/blob/26a1f6e1423ec53bf3bf4ba1c73e822942b27065/webcomic_reader.user.js#L54-L59

Steps to migrate:

I haven’t tested this script in Greasemonkey 4, but Greasemonkey 4 For Users implies that any functionality that relies on the @grants above will not work in Greasemonkey 4 until those calls are migrated. Since GM_xmlhttpRequest is one of the grants, it is likely that the core functionality of this script is broken in Greasemonkey 4.

anka-213 commented 5 years ago

The code is currently constructed in a fairly synchronous way and may require a major rewrite to completely get rid of the synchronous calls.

SoraHjort commented 10 months ago

My 2 cents: It might be unneeded to do a rewrite. Or at the very least, not worry about it for quite a long while.

As is, I think we should be unconcerned of needing to change when two of the three main engines haven't stated plans to phase out the old API. Which maybe is not the wisest of statements.

Even if Greasemonkey were to update after years of hiatus, and removed the old API completely, it'd probably be best to recommend using one of the other two. Not only because the script still works on them, but both are built for multiple browser engines. Greasemonkey's hold is Firefox only. I also don't think the other engines have incentive to remove the API since that would kill a lot of old scripts that don't get updates anymore.

Also, on a personal annoyance note, in it's current state, Greasemonkey's built in editor is terrible to do any live troubleshooting with. It would freeze up the whole extension when I would go and select all to paste a new version of the script into. Requiring task killing firefox itself to get it to stop. It ended up being quicker to just uninstall the script and creating a new one every time. Also it intercepts ctrl-f to do their own built in search function, which... finds the next result and then closes the search. So if you press enter more than once, well there went a line of code.

That personal note aside, let's worry about a rewrite when the others state plans to phase out. It should keep working regardless. Keep the issue open incase when that happens it manages to also break the fallbacks. But as is, I'm not inclined to believe it'll occur any time soon.