Javascript Safari中的Tampermonkey找不到xmlHttpRequest
我正在尝试使用本地Web服务器使用Tampermonkey存储来自网站的信息。使用Javascript Safari中的Tampermonkey找不到xmlHttpRequest,javascript,safari,tampermonkey,gm-xmlhttprequest,Javascript,Safari,Tampermonkey,Gm Xmlhttprequest,我正在尝试使用本地Web服务器使用Tampermonkey存储来自网站的信息。使用GM\u setvalue时,这些值似乎太大 为了调用本地服务器,我使用了GM\uxmlhttprequest。但是,控制台显示了一个错误: 错误:执行脚本“测试”失败!找不到变量:GM_xmlhttpRequest 我在Mac OS上使用Safari // ==UserScript== // @name Test // @namespace http://tampermonkey.net/
GM\u setvalue
时,这些值似乎太大
为了调用本地服务器,我使用了GM\uxmlhttprequest
。但是,控制台显示了一个错误:
错误:执行脚本“测试”失败!找不到变量:GM_xmlhttpRequest
我在Mac OS上使用Safari
// ==UserScript==
// @name Test
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://localhost/*
// @grant none
// @grant GM_xmlhttpRequest
// ==/UserScript==
//unsafeWindow.console.log("Requesting stuff!");
GM_xmlhttpRequest({
method: 'GET',
url: 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&revids=375536&rvdiffto=prev&format=xml',
onload: function(response) {
var xml = new DOMParser()
.parseFromString(response.responseText, "text/xml");
unsafeWindow.console.log("The response was: ", xml);
}
});
确认您正在使用Tampermonkey(或其他什么)?Greasemonkey在Safari上不起作用。此外,请删除
/@grant none
行,并将该行/@connect wikipedia.org
添加到元数据块中。。。如果需要,请卸载脚本,关闭浏览器,然后重新安装脚本。感谢您,我的主要问题是“无授权”行。愚蠢的康比酱。事实上,我用的是捣乱猴子