// ==UserScript== // @name 图书馆抢座位 // @namespace http://tampermonkey.net/ // @version 0.3 // @description 图书馆抢座位! // @author LXY // @match https://10-21-95-57.webvpn.cueb.edu.cn/ClientWeb/xcus/ic2/Default.aspx* // @grant none // @downloadURL none // ==/UserScript== function charge(){ var xhr = new XMLHttpRequest(); xhr.onload = function () { var i=document.getElementById("seati").innerText; var active=document.getElementById("active"); var textn; console.log("进来了"); if(xhr.responseText.indexOf("要到")>1){ console.log("时间还没到!"+new Date().toLocaleTimeString('cn',{hour12:false})); active.innerHTML = ""; textn = document.createTextNode("时间还没到:"+new Date().toLocaleTimeString('cn',{hour12:false})) //var textn=document.getElementById("textn"); //textn.innerText="时间还没到!"+new Date().toLocaleTimeString('cn',{hour12:false}) //textn.nodeValue="正在抢座"; }else if(xhr.responseText.indexOf("已有")>1){ active.innerHTML = ""; textn = document.createTextNode("已有预约成功") active.appendChild(textn); location.reload(); //clearInterval(interval); }else if(xhr.responseText.indexOf("成功")>1){ console.log("预约成功了!"); document.getElementById("seat"+i).innerText+="预约成功"; active.innerHTML = ""; textn = document.createTextNode("预约成功") active.appendChild(textn); document.getElementById("user_center").click(); }else if(xhr.responseText.indexOf("未登录")>1){ active.innerHTML = ""; textn = document.createTextNode("你未登录!") active.appendChild(textn); pro.d.lg.login(); clearInterval(interval); }else if(xhr.responseText.indexOf("冲突")>1){ document.getElementById("seat"+i).innerText="冲突"; document.getElementById("seati").innerText=++i; console.log("冲突!"); } } xhr.onerror = function () { console.log("请求出错"); } // 发送异步 GET 请求 xhr.open("GET",getURL(),true); xhr.send(); } var Shell = document.createElement("DIV"); Shell.id = "Shell"; Shell.style.position = "absolute"; Shell.style.left = "200px"; Shell.style.top = "100px"; Shell.style.width = "width:fit-content"; Shell.style.height = "width:fit-content"; Shell.style.textAlign = "center"; Shell.style.zIndex = "10000"; Shell.style.paddingLeft="10px"; Shell.style.paddingRight="10px"; //shield.style.padding="10px"; Shell.style.margin = "10px"; Shell.style.background = "#333"; Shell.style.color="#fff"; var strHtml = "
1
日期: 2021-"+(new Date().getMonth()+1)+"-"+(new Date().getDate()+1)+"
开始时间: 09:30
结束时间: 22:00
候选座位1: 2F161
候选座位2: 2F162
候选座位3: 2F163
候选座位4: 2F164
候选座位5: 2F165
候选座位6: 2F166
候选座位7: 2F167
候选座位8: 2F168
候选座位9: 2F169
"; Shell.innerHTML = strHtml; document.body.appendChild(Shell); var active=document.getElementById("active"); var textn = document.createTextNode("冲鸭! 点击开始抢座位!") textn.id = "textn"; active.appendChild(textn); var usercenter=document.getElementById("user_center"); if(document.getElementsByClassName("acc_info_id")[0].textContent!=""){ usercenter.click(); }else { pro.d.lg.login(); } active.onclick = function (e) { var interval = setInterval(charge,1000); active.style.pointerEvents="none"; textn.nodeValue="正在抢座"; e.stopPropagation();//阻止事件冒泡 } var seatObj ={"2F149":"100455875","2F150":"100455876","2F151":"100455877","2F152":"100455878","2F153":"100455879","2F154":"100455880","2F155":"100455881","2F156":"100455882","2F157":"100455883","2F158":"100455884","2F159":"100455885","2F160":"100455886","2F161":"100455887","2F162":"100455888","2F163":"100455889","2F164":"100455890","2F165":"100455891","2F166":"100455892","2F167":"114459838","2F168":"114459839","2F169":"114459840","2F170":"114459841","2F171":"114459842","2F172":"114459843","2F173":"114459844","2F174":"114459845","2F175":"114459846","2F176":"114459847","2F177":"114459848","2F178":"114459849"}; function getURL(){ var i=document.getElementById("seati").innerText; var date=document.getElementById("date").innerText; var start=document.getElementById("start").innerText; var end=document.getElementById("end").innerText; var seat=document.getElementById("seat"+i).innerText; var url="https://10-21-95-57.webvpn.cueb.edu.cn/ClientWeb/pro/ajax/reserve.aspx?dialogid=&dev_id="+seatObj[seat]+"&lab_id=&kind_id=&room_id=&type=dev&prop=&test_id=&term=&number=&classkind=&test_name=&start="+date+"+"+start.replace(/:|:/, "%3A")+"&end="+date+"+"+end.replace(/:|:/, "%3A")+"&start_time="+start.replace(/:|:/, "")+"&end_time="+end.replace(/:|:/, "")+"&up_file=&memo=&act=set_resv&_="+Date.now(); console.log(url); return url; }