// ==UserScript== // @name 登陆校园网 // @namespace hb123 // @version 0.1.2 // @description 登陆迅捷网络的校园网 // @author jw23 // @background // @crontab */5 * * * * * // @grant GM_registerMenuCommand // @grant unsafewindow // @grant GM_xmlhttpRequest // @grant GM_notification // @grant GM_getValue // ==/UserScript== /* ==UserConfig== configure: userId: title: 用户名 description: 输入校园网登陆的用户名 type: text default: "110" max: 10 password: title: 密码 description: 输入密码 type: text password: true ==/UserConfig== */ return new Promise((resolve, reject) => { // GM_registerMenuCommand("登陆", () => { // login() // }, "l") GM_xmlhttpRequest({ url:"https://www.baidu.com", method:"GET", onerror:()=>{ login() } }) }) function login() { const password = GM_getValue("configure.password", "") const userId = GM_getValue("configure.userId", "") GM_xmlhttpRequest({ url: "http://223.2.10.172/eportal/InterFace.do?method=login", "headers": { "accept": "*/*", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", "content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, data: `userId=${userId}&password=${password}&service=%25E8%2581%2594%25E9%2580%259A%25E6%259C%258D%25E5%258A%25A1&queryString=wlanuserip%253Df02d3ceebe91a66dfa4dba8b3d232138%2526wlanacname%253Db58fcda622d8bb5b%2526ssid%253D52eefd2d44d14e03%2526nasip%253De54b2b351c575112839c042a61804a4c%2526snmpagentip%253D%2526mac%253D820700b7bfabfcca9ca211ed5f5d8e52%2526t%253Dwireless-v2%2526url%253D2c0328164651e2b4f13b933ddf36628bea622dedcc302b30%2526apmac%253D%2526nasid%253Db58fcda622d8bb5b%2526vid%253D99b31e874c318e2f%2526port%253Dbbd009ed1ba7bad8%2526nasportid%253Df5eb983692924fa26e6431fe9df4835fd6ac8cb2c0e06b3ccf8e145f6fce50da47e4b57eb4fac4ed&operatorPwd=&operatorUserId=&validcode=&passwordEncrypt=false`, method: "POST", onload: () => { GM_notification({ text: "登陆成功", title: "校园网登陆提示" }); resolve("ok") }, onerror: (err) => { GM_notification({ text: "登陆失败,请再次尝试", title: "校园网登陆提示" }); reject("error") } }) }