ReferenceError: GM_xmlhttpRequest not defined

I get a ReferenceError in the following usercript code:

// ==UserScript== // @name ... // @namespace ... // @description ... // @include ... // @grant GM_xmlhttpRequest // ==/UserScript== console.log(GM_info); try { console.log(GM_xmlhttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState); } catch (e) { console.log(e); } ... 

It first logs GM_info successfully, then writes a ReferenceError. (I am using Firefox / Firebug.)

ReferenceError: GM_xmlhttpRequest not defined

Why am I getting this error?

+7
source share
3 answers

Reinstalling the script fixes the problem. I do not need to restart Firefox, but it can be useful for other people. Brock's answer provides helpful debugging tips for such problems.

+4
source

I had the same issue and this was fixed for me:

 // @grant GM_xmlhttpRequest 
+3
source

Starting with the news release (GM 4.0), this error occurred when using GM_xmlhttpRequest since GM_xmlhttpRequest was replaced by: GM.xmlHttpRequest .

New code:

 // ==UserScript== // @name ... // @namespace ... // @description ... // @include ... // @grant GM.xmlHttpRequest // ==/UserScript== console.log(GM_info); try { console.log(GM.xmlHttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState); } catch (e) { console.log(e); } //... 

Greasemonkey: "GM_xmlhttpRequest not defined" with new update

0
source

All Articles