Ken*_*rey 10 javascript greasemonkey gm-xmlhttprequest referenceerror
我在以下用户脚本代码中得到一个ReferenceError:
// ==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);
}
...
Run Code Online (Sandbox Code Playgroud)
它首先GM_info成功记录,然后记录ReferenceError.(我正在使用Firefox/Firebug.)
ReferenceError:未定义GM_xmlhttpRequest
为什么我会收到此错误?
小智 7
我遇到了同样的问题,为我解决的问题是在顶部添加了此问题:
// @grant GM_xmlhttpRequest
Run Code Online (Sandbox Code Playgroud)
从新闻版(GM 4.0)开始,这个错误在你使用时发生,GM_xmlhttpRequest因为GM_xmlhttpRequest被替换为 : GM.xmlHttpRequest。
新代码是:
// ==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);
}
//...
Run Code Online (Sandbox Code Playgroud)
Greasemonkey:带有新更新的“GM_xmlhttpRequest 未定义”
| 归档时间: |
|
| 查看次数: |
10145 次 |
| 最近记录: |