图书馆抢座位

图书馆抢座位!

目前为 2021-09-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         图书馆抢座位
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  图书馆抢座位!
// @author       LXY
// @match       https://10-21-95-57.webvpn.cueb.edu.cn/ClientWeb/xcus/ic2/Default.aspx
// @grant        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 = "<table border=\"1\">   <tr> <td id=\"seati\"  style=\"display:none\">1</td>    </tr>  <tr>        <td>日期:</td>        <td id=\"date\"  contentEditable=\"true\">2021-"+(new Date().getMonth()+1)+"-"+(new Date().getDate()+1)+"</td>    </tr>    <tr>        <td>开始时间:</td>        <td id=\"start\" contentEditable=\"true\" >09:30</td>    </tr>       <tr>        <td>结束时间:</td>        <td id=\"end\"  contentEditable=\"true\">22:00</td>    </tr>     </tr>      <tr>        <td>候选座位1:</td>        <td   id=\"seat1\"  contentEditable=\"true\">2F161</td>    </tr>      <tr>        <td>候选座位2:</td>        <td  id=\"seat2\"  contentEditable=\"true\">2F162</td>    </tr>    <tr>        <td>候选座位3:</td>        <td id=\"seat3\"  contentEditable=\"true\">2F163</td>    </tr>      <tr>        <td>候选座位4:</td>        <td id=\"seat4\" contentEditable=\"true\">2F164</td>    </tr>      <tr>        <td>候选座位5:</td>        <td id=\"seat5\" contentEditable=\"true\">2F165</td>    </tr>     <tr>        <td>候选座位6:</td>        <td id=\"seat6\"  contentEditable=\"true\">2F166</td>    </tr>     <tr>        <td>候选座位7:</td>        <td id=\"seat7\"  contentEditable=\"true\">2F167</td>    </tr>     <tr>        <td>候选座位8:</td>        <td id=\"seat8\"  contentEditable=\"true\">2F168</td>    </tr>    <tr>        <td>候选座位9:</td>        <td id=\"seat9\"  contentEditable=\"true\">2F169</td>    </tr>    <tr>        <td id=\"active\"  colspan=\"2\"   text_align=\"center\"  >   </td>    </tr></table>";
	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;

 }



QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址