为什么这个简单的Greasemonkey脚本对我不起作用,https://jsfiddle.net/pghnsw8z/1/?我的意思是,在进行ajax调用时,我得到的不是成功的响应,而是错误。
// ==UserScript==
// @name _Starter AJAX request in GM, TM, etc.
// @match *://php.net/*
// @grant GM_xmlhttpRequest
// @connect php.net
// ==/UserScript==
GM_xmlhttpRequest ( {
method: 'GET',
url: 'http://php.net/',
onload: function (responseDetails) {
// DO ALL RESPONSE PROCESSING HERE...
alert(responseDetails);
console.log (
"GM_xmlhttpRequest() response is:\n",
responseDetails.responseText.substring (0, 80) + '...'
);
}
} );
我在这里找到了https://stackoverflow.com/a/42592356/9483949的脚本,它似乎对之前的某个人很有效。
我使用的是Firefox 59.0.1和Greasemonkey 4.3
重新启动Firefox和重新安装脚本没有帮助。
发布于 2019-01-31 08:52:11
文档:https://wiki.greasespot.net/GM.xmlHttpRequest
GM API已更改。你必须使用GM类的xmlHttpRequest属性,它是兼容性的: GM 4.0+。
使用:GM.xmlHttpRequest
替换GM_xmlhttpRequest
,如下所示:
// ==UserScript==
// ...
// @grant GM.xmlHttpRequest
// ==/UserScript==
GM.xmlHttpRequest({
https://stackoverflow.com/questions/49365651
复制相似问题