I'm using a function in a userscript that I'm writing which does not work in Greasemonkey due to the limitations of Greasemonkey. This function is not necessary for proper operation of the userscript, but it improves user experience, so I don't want to just remove it entirely.
I tried using a try { ... } catch() { ... }
block, but unfortunately Greasemonkey ceases execution of the script as soon as it attempts execution of the function instead of throwing an exception. So I instead decided to prevent execution of the function when the script is loaded via Greasemonkey, but I have been unable to find a method of doing that.
- I've read through the API reference, but was unable to find anything useful.
- I found this github issue that would allow detection of Greasemonkey but that seems to have been "fixed" now.
- I looked through this topic on userscripts-mirror.org, but the proposed solution in that thread checks for the existence of GM* functions, which are also available in most other userscript managers (specifically Tampermonkey and Violentmonkey which support the function that Greasemonkey does not).
How can I go about detecting whether the active userscript manager is Greasemonkey or not?