我在以下用户脚本代码中收到 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);
}
...
它首先成功记录 GM_info
,然后记录 ReferenceError。 (我正在使用 Firefox/Firebug。)
ReferenceError: GM_xmlhttpRequest is not defined
为什么会出现此错误?
最佳答案
我有同样的问题,为我解决的是在顶部添加这个:
// @grant GM_xmlhttpRequest
关于javascript - ReferenceError:未定义 GM_xmlhttpRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16736320/