// ==UserScript==
// @name first script
// @namespace http://tampermonkey.net/
// @match http://192.168.2.161:8082
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://192.168.2.161:8082/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant GM_registerMenuCommand
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
'use strict';
console.log("srcipt enabled");
GM_registerMenuCommand("加入新页面",function(){
let url =location.href;
console.log("url:"+url);
let pos1 = url.indexOf("#");
let pos2 = url.indexOf("?",pos1);
let page = "";
if(pos2 != -1){
page = url.substring(pos1 + 2,pos2);
}else{
page = url.substring(pos1 + 2);
}
let newurl = "http://im.n8y.test/api/add_page_to_wechat_debug?page=" + page;
console.log("打开新窗口url:"+newurl);
GM_xmlhttpRequest({
method: "get",
url: newurl,
onload: function(res){
if(res.status === 200){
console.log('新页面加入成功')
}else{
console.log('新页面加入失败')
console.log(res)
}
},
onerror : function(err){
console.log('error')
console.log(err)
}
});
//GM_openInTab(newurl, { active: true, insert: true, setParent :true })
},"h");
})();