// ==UserScript==
// @name New Userscript
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.0
// @description try to take over the world!
// @author You
// @match *
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @console log
// ==/UserScript==
return new Promise((resolve, reject) => {
getData().then((data)=>{
return parseData(data)
}).then((data)=>{
console.log(data)
})
resolve();
});
function getData(){
return new Promise((resolve)=>{
GM_xmlhttpRequest({
url:"http://httpbin.org/get",
method :"GET",
headers: {
"Content-type": "application/x-www-form-urlencoded"
},
onload:function(xhr){
console.log(xhr.responseText)
resolve(xhr.responseText)
}
});
})
}
function parseData(data){
return new Promise((resolve)=>{
setTimeout(()=>{
console.log(JSON.parse(data).origin)
resolve("解析完成")
},2)
})
}