GM.xmlHttpRequest is not a function

1,919 views
Skip to first unread message

Brent Bartlett

unread,
Aug 21, 2018, 12:11:47 AM8/21/18
to greasemonkey-users
I've been working my way through Mark Pilgrim's Dive Into Greasemonkey. It's obviously a bit antiquated now, but I've been able to get all of the scripts working with some tweaks here and there.

One that's really got me stumped, though, is the exercise for 4.23 "Parsing XML". According to the wiki, GM_xmlhttpRequest has been replaced by GM.xmlHttpRequest. However, simply changing the name did not work. The console gave me this error:

Script error: TypeError: "GM.xmlHttpRequest is not a function"

So, perhaps there's something wrong with the code? Well, no, because even copying and pasting the example code for GM.xmlHttpRequest() doesn't work! (This is the "bare minimum" code from https://wiki.greasespot.net/GM.xmlHttpRequest .) Same error, every time.

Anthony Lieuallen

unread,
Aug 21, 2018, 9:13:08 AM8/21/18
to greasemon...@googlegroups.com
Since several years ago, you must explicitly request access to privileged APIs:


This applies even to the examples (we should probably "upgrade" those examples to entire user scripts, with the @grant ...)
Reply all
Reply to author
Forward
0 new messages