Firefox quantum is out and it feels great!
Many things became faster and the new UI is... not completely bad. I like how describing text is returning.
One thing that changed is what extensions can do and that they focus more on running asynchronous.
This means that the new Firefox requires new extension versions for various extensions. This also includes Greasemonkey.
And Greasemonkey decided to drop backwards-compatibility by default.
That's why almost all of my scripts stopped working in the new Firefox.
There is a backwards-compatibility solution, but I have to add it by hand.
This is also not just a header thing, but something you need to go through your script and rewrite parts that are affected.
I'm currently going through my scripts and update them.
It might take a while, though, since some are rather large and there are around 30 scripts in total...
So, please bear with me while I'm working on this.
In userscript GM-API-Calls all _ are replaced with .:
GM_getValue becomes GM.getValue.
Also GM.xmlHttpRequest has now a large H... before lower ones were ignored I guess.
GM.getValue doesn't return a value anymore, but a "promise" and runs asynchronous.
It HAS TO run in an asynchronous function, otherwise you get a cryptic console-error-message that a script failed to run.
Asynchronous functions have the async-prefix.
To let GM.getValue run synchronous and return its value, you need a prefix await.
var name=await GM.getValue("myName");
Be careful with asynchronouse functions! The browser does not guarantee that the async function is executed before the next statement. In fact on most devices it is executed in parallel:
i=await GM.getValue("di"); //di stored is 2
Here i is either 2 or 3, depending on the device and how busy it is at the moment. Make sure you put everything depending on GM.getValue also inside, if you don't want to introduce safe-flags or singletons in your code.
GM.getValue and GM.xmlHttpRequest seem to require async functions. GM.setValue can run without, but is still executed asynchronously!
They also dropped registerMenuCommand and AddStyle, but at least the second can be written by your own easily.
Now comes the real mess: While the new Greasemonkey supports the new GM-API-Calls, old Greasemonkey versions do not. Also most probably Scriptisch, ViolentMonkey and Tampermonkey will take a while to keep up.
So, to not break the script for older devices by fixing it for newer one, you need backwards compatibility.
According to Greasemonkey this is easy: www.greasespot.net/2017/09/gre…
You just need to include their "polyfill" script and request @ grants for old and new API-Calls (remove blank space after @):
// @ grant GM_xmlhttpRequest
// @ grant GM_getValue
// @ grant GM_setValue
// @ grant GM.xmlHttpRequest
// @ grant GM.getValue
// @ grant GM.setValue
// @ require greasemonkey.github.io/gm4-pol…
At least in my Tampermonkey on Chrome this seems to work.
However, this also asks the user to allow a new source for the script (greasemonkey.github.io)
As a side note, it is also told that installing new userscripts in firefox will not work from github.
Good thing I have mirrors for my links. ^^