Greasy Fork

Greasy Fork is available in English.

东南大学研究生人文讲座脚本ACupofAir

东南大学研究生抢讲座

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         东南大学研究生人文讲座脚本ACupofAir
// @namespace    http://nic.seu.edu.cn/
// @version      2024-04-07
// @description  东南大学研究生抢讲座
// @author       OminousBlackCat, ACupofAir
// @match        *://ehall.seu.edu.cn/gsapp/sys/jzxxtjapp/*
// @icon         http://pic.5tu.cn/uploads/allimg/1510/081431395820.jpg
// @match        http://ehall.seu.edu.cn/gsapp/sys/jzxxtjapp/*default/index.do?t_s=1712476611421&EMAP_LANG=zh&THEME=indigo&amp_sec_version_=1&gid_=MGRuVDdWWVRkaWkvSG5VcTBONHpjVjg2dU9BT0dNMEpQNGdiNUQ2dzQyUVJFTHFCK3V5M3BzTkdsRmdBckhxeW41Y0tGVEtiYkEyaWM1ZHBrWUY4OUE9PQ
// @icon         https://www.google.com/s2/favicons?sz=64&domain=seu.edu.cn
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @grant        unsafeWindow
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-end
// ==/UserScript==
// tite: 东南大学研究生素质讲座预定脚本
// author: ACupofAir
// e-mail: [email protected]
console.log("SEU Lecture Book Script Loaded")
let postInterval = 300 //每次post的时间间隔 推荐100-300ms
setTimeout(function () {
    document.querySelector("body > main > article > div").style.display = "none"
    let all_wid = $("[data-x-wid]").map(function () { return $(this).attr("data-x-wid"); }).get()

    //===============verify code===============
    let newVcode = document.createElement("img")
    newVcode.id = "tempImage"
    let verifyCode = document.createElement("input")
    verifyCode.id = "tempInput"
    verifyCode.style = "width:6em; height:1.2em; "
    verifyCode.placeholder = "请输入验证码"
    let flashBtn = document.createElement("button")
    flashBtn.textContent = "获取验证码"
    flashBtn.style = "width:6em; font-size: 1.0em; margin-right:3em"
    flashBtn.addEventListener("click", function () {
        let temp_data = BH_UTILS.doSyncAjax(baseUrl + '/hdyy/vcode.do' + '?_=' + new Date().getTime(), {})
        $("#tempImage").attr('src', temp_data.result)
    })

    $("h2").append(newVcode)
    $("h2").append(verifyCode)
    $("h2").append(flashBtn)

    newVcode.addEventListener("click", function () {
        let temp_data = BH_UTILS.doSyncAjax(baseUrl + '/hdyy/vcode.do' + '?_=' + new Date().getTime(), {})
        $("#tempImage").attr('src', temp_data.result)
    })


    //===============time setting===============
    // Create a new time input
    let timeInput = document.createElement("input");
    timeInput.type = "time";
    timeInput.id = "myTime";
    $("h2").append(timeInput);


    //===============lecture setting===============
    let selectList = document.createElement("select");
    selectList.id = "mySelect";
    for (let i = 1; i <= all_wid.length; i++) {
        let option = document.createElement("option");
        option.value = i;
        option.text = i.toString();
        selectList.appendChild(option);
    }
    $("h2").append(selectList);

    let submitBtn = document.createElement("button")
    submitBtn.textContent = "√"
    submitBtn.addEventListener("click", function () {
        let selectedTimeValue = document.getElementById("myTime").value;
        if (selectedTimeValue) {
            let [hours, minutes] = selectedTimeValue.split(":");
            let selectedTime = new Date();
            selectedTime.setHours(+hours);
            selectedTime.setMinutes(+minutes);
            selectedTime.setSeconds(0);
            selectedTime.setMilliseconds(0)

            let diff = selectedTime.getTime() - new Date().getTime();
            let verifyCode = $("#tempInput").val()
            diff += 100;
            
            let lectureId = selectList.value;

            if (diff < 0) {
                alert("The selected time is in the past. Please select a future time.");
            } else {
                alert(`将于${diff/1000}s后抢第${lectureId}个课, 验证码为${verifyCode},点击ok后耐心等待`);
                let foo = { HD_WID: all_wid[lectureId-1], vcode: verifyCode }
                console.log(foo);
                setTimeout(function () {
                    BH_UTILS.doAjax(baseUrl + '/hdyy/yySave.do', { paramJson: JSON.stringify(foo) }).done(function (data) {
                        console.log(data.msg)
                    });
                    alert("抢讲座结束");
                }, diff);
            }
        } else {
            alert("Please select a time.");
        }
    });

    $("h2").append(submitBtn)
}, 1200);