scriptcat
scriptcat copied to clipboard
responseType: "document" 不支持
GM_xmlhttpRequest({
method: "GET",
url: "https://bbs.kanxue.com/",
responseType: "document",
onload: xhr => console.log(xhr),
onerror: () => console.log('网络错误')
});

看起来是后台脚本的运行环境,后台脚本暂时不支持document,可以加入后续更新计划
看起来是后台脚本的运行环境,后台脚本暂时不支持document,可以加入后续更新计划 普通脚本运行也是失败的,请求是正常发出并且响应也没问题
这样运行还是在后台脚本的环境中,普通脚本是指的有@match的脚本,例如:
// ==UserScript==
// @name New Userscript
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.0
// @description try to take over the world!
// @author You
// @match https://bbs.tampermonkey.net.cn/
// @grant GM_xmlhttpRequest
// ==/UserScript==
GM_xmlhttpRequest({
url: "https://bbs.tampermonkey.net.cn/",
responseType: "document",
onload(data) {
console.log(data.response);
}
})
然后打开链接:https://bbs.tampermonkey.net.cn/
后台脚本,暂时不打算也不太好支持此功能
需要的话,可以考虑通过三方库去解析responseText成document
