violentmonkey: [BUG] `GM.xmlHttpRequest()` returns non-200 response
Sequence of actions:
- Install GitHub Star History userscript
- Visit https://github.com/violentmonkey/violentmonkey (or any repo) with script active in Violentmonkey
- Observe in console that
insertStarHistory()
failed to fetch image
Problem:
GitHub Star History ⭐.user.js:416 Error loading star history chart: Error: Failed to fetch image at insertStarHistory (GitHub Star History ⭐.user.js:391:19)
Expected result:
Return 200 instead of some abort
obj as observed when response logging is added to the function, like Tampermonkey successfully does when running the same function in Chrome, Edge, Vivaldi, Firefox, Opera, Ghost, QQ & Whale
Devtools console contents:
When response logging is added:
Environment:
- OS: Windows
- Browser: Vivaldi Version 6.6.3271.57 (Official Build) (64-bit) (I don’t use VM/Vivaldi, but a user reported the issue in this env, so that’s where I confirmed his suspicion the function doesn’t work)
- Violentmonkey Version: 2.18.0
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Comments: 42 (16 by maintainers)
Commits related to this issue
- Removed VM from compatibility (violentmonkey/violentmonkey#2068, violentmonkey/violentmonkey#2069) — committed to EthicalSecurity-Agency/KudoAI-googlegpt by adamlui 3 months ago
- Removed VM from compatibility (violentmonkey/violentmonkey#2068, violentmonkey/violentmonkey#2069) ↞ [auto-sync from `root`] — committed to EthicalSecurity-Agency/KudoAI-googlegpt by adamlui 3 months ago
I didn’t value my life for a long time so I didn’t know when to stop and got myself in situations where I nearly died several times.
You’re looking at the awaited result i.e.
await GM.xmlHttpRequest()
.To see the returned result of the function you should look at
GM.xmlHttpRequest()
. You’ll see that in the specification it’sundefined
, in Violentmonkey it’s a control object withabort
inside, in Tampermonkey it’sPromise
withabort
inside.You can’t use
await
anywhere except Tampermonkey if you want your script to be compatible with other specification-compliant managers.You can use the same approach you’ve already used in your updateCheck().
You can also combine it with the standard promisification technique:
Tampermonkey’s approach is not always wise.
But we don’t.