自动抢课2

自动抢课21

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         自动抢课2
// @namespace    https://osu.ppy.sh/u/376831
// @version      0.1
// @description  自动抢课21
// @author       wcx19911123
// @match        http://192.168.240.168/xuanke/edu_main.asp?xq=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!==null)return  unescape(r[2]); return null;
    }
    var course_no = GetQueryString("course_no");
    var isBixiu = GetQueryString("bx");
    var input;
    var eventId = setInterval(function(){
        input = parent.window.frames.button.document.getElementsByName("kch");
        if(input !== null && input.length > 0){
            clearInterval(eventId);
            input = input[0];
            if(course_no){
                input.value = course_no;
                input = parent.window.frames.button.document.getElementsByName("action1")[0];
                input.click();
                eventId =  setInterval(function(){
                    input = parent.window.frames.course.document.getElementsByTagName("input");
                    if(input !== null && input.length > 0){
                        clearInterval(eventId);
                        input = input[(isBixiu == 1 ? 0 : 1)];
                        input.checked = true;
                        parent.window.frames.button.document.getElementsByName("action5")[0].click();
                        eventId =  setInterval(function(){
                            input = parent.window.frames.result.document.getElementsByName("GetCode");
                            if(input !== null && input.length > 0){
                                clearInterval(eventId);
                                input = input[0];
                                input.focus();
                            }
                        }, 200);
                    }
                }, 200);
            }
        }
    }, 200);
})();