admin管理员组文章数量:1277900
I'm seriously struggling trying to resolve an issue with my script. Whatever I try and do GM.xmlHttpRequest throws error "is not a function".
The rest of my code works fine.
This is an abridged version of my code:
// ==UserScript==
// @name FUT20 Autobuyer Menu
// @namespace /
// @version 0.6
// @description try to take over the world!
// @author Rastor
// @match /*
// @match /*
// @grant GM.xmlHttpRequest
// ==/UserScript==
try {
GM.xmlHttpRequest({
method: "GET",
url: "/",
onload: function(response) {
alert(response.responseText);
}
});
}
catch (err) {
console.log(err);
}
I'm seriously struggling trying to resolve an issue with my script. Whatever I try and do GM.xmlHttpRequest throws error "is not a function".
The rest of my code works fine.
This is an abridged version of my code:
// ==UserScript==
// @name FUT20 Autobuyer Menu
// @namespace http://tampermonkey/
// @version 0.6
// @description try to take over the world!
// @author Rastor
// @match https://www.easports./uk/fifa/ultimate-team/web-app/*
// @match https://www.easports./fifa/ultimate-team/web-app/*
// @grant GM.xmlHttpRequest
// ==/UserScript==
try {
GM.xmlHttpRequest({
method: "GET",
url: "http://www.example./",
onload: function(response) {
alert(response.responseText);
}
});
}
catch (err) {
console.log(err);
}
Share
Improve this question
edited Jun 8, 2020 at 11:02
Matt Bridges
asked Jun 8, 2020 at 10:38
Matt BridgesMatt Bridges
1711 gold badge3 silver badges10 bronze badges
4
-
The code is missing
// ==UserScript==
at the beginning. – woxxom Commented Jun 8, 2020 at 10:44 - It is but unfortunately that's just how it's copied in. Everything else is working. – Matt Bridges Commented Jun 8, 2020 at 10:53
- I've edited the post above to show what the code actually looks like. I had missed that line in the post above. When it appears in the actual code it still doesn't work. – Matt Bridges Commented Jun 8, 2020 at 11:02
- 1 Since the posted code works for me I guess there's a bug in your version of Tampermonkey or browser or there's a typo in your actual code. – woxxom Commented Jun 8, 2020 at 11:07
2 Answers
Reset to default 7In Tampermonkey it is GM_xmlhttpRequest
(underscore not dot) as the privilege and function name!
In my scenario, I had to enable the call with the below grant:
// @grant GM.xmlHttpRequest
I was then able to plete the request.
本文标签: javascriptTampermonkey GMxmlHttpRequest is not a functionStack Overflow
版权声明:本文标题:javascript - Tampermonkey GM.xmlHttpRequest is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741287567a2370360.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论