Why this simple Greasemonkey script is not working for me / ? I mean that instead of getting successful response I get error while making an ajax call.
// ==UserScript==
// @name _Starter AJAX request in GM, TM, etc.
// @match *://php/*
// @grant GM_xmlhttpRequest
// @connect php
// ==/UserScript==
GM_xmlhttpRequest ( {
method: 'GET',
url: '/',
onload: function (responseDetails) {
// DO ALL RESPONSE PROCESSING HERE...
alert(responseDetails);
console.log (
"GM_xmlhttpRequest() response is:\n",
responseDetails.responseText.substring (0, 80) + '...'
);
}
} );
I found the script here and it seems it worked well for someone earlier.
I'm using Firefox 59.0.1 and Greasemonkey 4.3
Restarting Firefox and reinstalling script didn't help.
Why this simple Greasemonkey script is not working for me https://jsfiddle/pghnsw8z/1/ ? I mean that instead of getting successful response I get error while making an ajax call.
// ==UserScript==
// @name _Starter AJAX request in GM, TM, etc.
// @match *://php/*
// @grant GM_xmlhttpRequest
// @connect php
// ==/UserScript==
GM_xmlhttpRequest ( {
method: 'GET',
url: 'http://php/',
onload: function (responseDetails) {
// DO ALL RESPONSE PROCESSING HERE...
alert(responseDetails);
console.log (
"GM_xmlhttpRequest() response is:\n",
responseDetails.responseText.substring (0, 80) + '...'
);
}
} );
I found the script here https://stackoverflow./a/42592356/9483949 and it seems it worked well for someone earlier.
I'm using Firefox 59.0.1 and Greasemonkey 4.3
Restarting Firefox and reinstalling script didn't help.
Share Improve this question edited Jan 31, 2019 at 8:48 user2226755 13.3k6 gold badges54 silver badges75 bronze badges asked Mar 19, 2018 at 14:43 PeterPeter 211 silver badge3 bronze badges 7- 2 GM4 has abandoned the classic API, see their documentation, now it's GM.* – woxxom Commented Mar 19, 2018 at 15:17
-
@wOxxOm In this case I get
GM.xmlhttpRequest is not a function
– Peter Commented Mar 19, 2018 at 15:39 - 1 The new API function uses uppercase H. – woxxom Commented Mar 19, 2018 at 16:14
- @wOxxOm Perfect! thank's a lot. – Peter Commented Mar 19, 2018 at 16:20
- 1 Peter, as per GM's own remendation, you should switch to Tampermonkey or Violentmonkey. The new Greasemonkey is severely degraded, not backwards patible, and has significantly less utility than the other engines. – Brock Adams Commented Mar 19, 2018 at 18:56
1 Answer
Reset to default 4The doc : https://wiki.greasespot/GM.xmlHttpRequest
The GM API was changed. You have to use xmlHttpRequest property of GM class, it is patibility: GM 4.0+.
Replace GM_xmlhttpRequest
by : GM.xmlHttpRequest
like this :
// ==UserScript==
// ...
// @grant GM.xmlHttpRequest
// ==/UserScript==
GM.xmlHttpRequest({