您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
听说你抢不到课
当前为
// ==UserScript== // @name 东南大学抢课助手new // @namespace http://tampermonkey.net/ // @version 0.2 // @description 听说你抢不到课 // @author realhuhu // @match http://newxk.urp.seu.edu.cn/xsxk/elective/grablessons?* // @icon https://huhu-1304907527.cos.ap-nanjing.myqcloud.com/share/qkzs // ==/UserScript== (function () { 'use strict'; onload; // let jwt = sessionStorage.token; let ajax = axios.create(); grablessonsVue.grabList = { "TJKC": [], "FANKC": [], "FAWKC": [], "TYKC": [], "XGKC": [], }; grablessonsVue.grabRes = []; (self => { let app = document.getElementById("xsxkapp") self.mount = () => { self.createTag() self.createPanel() } self._createWrap = id => { let wrap = document.createElement("div") wrap.setAttribute("id", id) return wrap } self.createTag = () => { let wrap = self._createWrap("tag") wrap.innerHTML = ` <div class="slideMenu" style="top: 250px;left:30px;width: 40px;" onclick="grablessonsVue.patch.toggle()"> <div class="centre-btn item el-icon-date"> </div> </div> ` app.appendChild(wrap) } self.createPanel = () => { let wrap = self._createWrap("panel") wrap.style.display = "none" wrap.innerHTML = ` <div style="position: fixed;right: 0;top:0 ;z-index: 114514;width: 350px; height: 100%;background-color: rgba(61,72,105,0.8)"> <hr> <h1 style="color: #c7e6e6; text-align: center">东大抢课脚本</h1> <hr> <div> <input id="enter" type="text" class="el-input__inner" style="width: 96%;margin-left: 2%;height: 30px" placeholder="输入课程代码(不区分大小写),按回车确定" onkeydown="grablessonsVue.patch.enterCourse(\'' + event + '\')"> </div> <div id="list-wrap" style="overflow: auto;margin: 10px;border:1px solid white;height: 50%"> <h3 style='text-align: center;color:lightblue;margin-top: 50%'>还未选择课程</h3> </div> <button id="grab" type="button" style="display: flex;float: right;" class="el-button el-button--default el-button--large is-round" onclick="grablessonsVue.patch.grab()">一键抢课</button> <div style="position: fixed;bottom: 20%;right: 2%"> <h5 style="color: white" onclick="grablessonsVue.patch.show()">显示结果</h5> </div> <div style="position: fixed;bottom: 10%;right: 2%"> <h5 style="color: white">课程代码:课程号+教师号</h5> </div> </div> ` app.appendChild(wrap) } })(grablessonsVue.Components = grablessonsVue.Components || {}); grablessonsVue.patch = { toggle() { let node = document.getElementById("panel") node.style.display === "block" ? node.style.display = "none" : node.style.display = "block" }, enterCourse(e) { let evt = window.event || e; if (evt.keyCode === 13) { let target = document.getElementById("enter") let id = "202120221" + target.value.toUpperCase() let type = grablessonsVue.teachingClassType let course = {} if (type === "TJKC") { } else if (type === "FANKC") { } else if (type === "FAWKC") { } else if (type === "TYKC") { for (let i of grablessonsVue.courseList[0].tcList) { if (i.JXBID === id) { course["id"] = id course["name"] = i.KCM course["teacher"] = i.SKJS course["key"] = i.secretVal } } } else if (type === "XGKC") { for (let i of grablessonsVue.courseList) { if (i.JXBID === id) { course["id"] = id course["name"] = i.KCM course["teacher"] = i.SKJS course["key"] = i.secretVal } } } if (JSON.stringify(course) !== '{}') { grablessonsVue.grabList[type].push(course) grablessonsVue.$message({ type: "success", message: "添加成功" }) } else { grablessonsVue.$message({ type: "warning", message: "课程代码错误,请检查后重新输入" }) } target.value = "" document.getElementById("list-wrap").innerHTML = grablessonsVue.patch.createList() } }, grab() { grablessonsVue.grabRes = [] let data = [] for (let type of Object.keys(grablessonsVue.grabList)) { for (let raw of grablessonsVue.grabList[type]) { data.push({ clazz: raw.name, dic: { clazz: raw.name, clazzType: type, clazzId: raw.id, secretVal: raw.key } }) } } document.getElementById("grab").innerText = "请耐心等待" axios.all(data.map(raw => { return ajax({ url: "/elective/clazz/add", method: "POST", headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: Qs.stringify(raw.dic) }).then(function (response) { let type = response.data.code === 100 ? "success" : "warning" grablessonsVue.grabRes.push({ clazz: raw.clazz, msg: response.data.msg }) grablessonsVue.$message({ type, message: raw.clazz + ":" + response.data.msg }) }).catch(function (error) { grablessonsVue.$message({ type: "error", message: "未知错误:" + error }); }) })).then(function () { if (Object.keys(grablessonsVue.grabList).map(type => grablessonsVue.grabList[type].length).reduce((x, y) => x + y)) { grablessonsVue.$message({ type: "success", message: "抢课结束" }) document.getElementById("grab").innerText = "再次抢课" } else { grablessonsVue.$message({ type: "warning", message: "请选择课程" }) document.getElementById("grab").innerText = "一键抢课" } } ) }, createList() { let courses = [] for (let type of Object.keys(grablessonsVue.grabList)) { for (let course of grablessonsVue.grabList[type]) { courses.push({ id: course.id, name: course.name, teacher: course.teacher }) } } if (courses.length === 0) { return `<h3 style='text-align: center;color:lightblue;margin-top: 50%'>还未选择课程</h3>` } else { let html = ` <table width="100%" border="1" style="background-color: rgba(0,0,0,0);color: lightblue"> <tr style="height: 30px;background-color: #255e95"> <th style="text-align:center;width: 60%">课程</th> <th style="text-align:center;width: 20%">教师</th> <th style="text-align:center;width: 20%">操作</th> </tr> ` for (let course of courses) { html += '<tr style="height: 30px"><td style="text-align: center">' + course.name + '</td><td style="text-align: center">' + course.teacher + '</td><td style="text-align: center"><button onclick="grablessonsVue.patch.removeCourse(\'' + course.id + '\')">删除</button></td></tr>' } html += "</table>" return html } }, removeCourse(id) { console.log(id); let n = 0 for (let type of Object.keys(grablessonsVue.grabList)) { for (let course of grablessonsVue.grabList[type]) { if (course.id === id) { n = grablessonsVue.grabList[type].indexOf(course) grablessonsVue.grabList[type].splice(n, 1); } } } document.getElementById("list-wrap").innerHTML = grablessonsVue.patch.createList() }, show(){ alert(grablessonsVue.grabRes.map(res => res.clazz+":"+res.msg).join("\n")) } }; grablessonsVue.Components.mount(); })();