Greasemonkey:新更新中“未定义 GM_xmlhttpRequest”

2024-03-29

为什么这个简单的 Greasemonkey 脚本对我不起作用https://jsfiddle.net/pghnsw8z/1/ 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 https://stackoverflow.com/a/42592356/9483949看起来这对早期的某人来说效果很好。

我使用的是 Firefox 59.0.1 和 Greasemonkey 4.3

重新启动 Firefox 并重新安装脚本没有帮助。


该文件:https://wiki.greasespot.net/GM.xmlHttpRequest https://wiki.greasespot.net/GM.xmlHttpRequest

GM API 已更改。您必须使用 GM 类的 xmlHttpRequest 属性,它的兼容性:GM 4.0+。

Replace GM_xmlhttpRequest by : GM.xmlHttpRequest像这样 :

// ==UserScript==
// ...
// @grant         GM.xmlHttpRequest
// ==/UserScript==

GM.xmlHttpRequest({
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Greasemonkey:新更新中“未定义 GM_xmlhttpRequest” 的相关文章