RUC Campus Access Enhancer

Streamline and optimize Renmin University of China campus access with this userscript.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         RUC Campus Access Enhancer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @license      MIT
// @description  Streamline and optimize Renmin University of China campus access with this userscript.
// @author       andylizf
// @homepage     https://github.com/andylizf/RUC-Campus-Access-Enhancer
// @match        http://appointment.ruc.edu.cn/index/apply/apply/RULEID/364
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ruc.edu.cn
// @require      https://code.jquery.com/jquery-3.7.1.min.js
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    let $ = window.jQuery;

    var tasks = [
        {
            selector: '.re',
            operation: e => e.hide()
        },
        {
            selector: '#INFOTYPE3',
            operation: e => { e.val(5); e.change() }
        },
        {
            selector: 'input[name="RESON"]',
            operation: e => e.val('入校参观')
        },
        {
            selector: '#info0',
            operation: e => e.prop('checked', true)
        },
        {
            selector: '#info1',
            operation: e => e.prop('checked', true)
        },
        {
            selector: '#info2',
            operation: e => e.prop('checked', true)
        },
        {
            selector: '.re[style*="display: block;"]',
            operation: e => { $(".his_bg1").css('display', 'block'); e.hide(); }
        },
        {
            selector: 'input[type="checkbox"]',
            operation: e => e.prop('checked', true)
        },
        {
            selector: 'button[onclick="formsub(2)"]',
            operation: e => e.click()
        },
    ];

    function executeTasks(index) {
        if (index < tasks.length) {
            var task = tasks[index];
            var operation = task.operation;

            var interval = setInterval(function () {
                var element = $(task.selector);
                if (element.length > 0) {
                    console.log("Executing task " + index + " on " + element);
                    operation(element);
                    clearInterval(interval);
                    executeTasks(index + 1);
                }
            }, 50);
        }
    }

    executeTasks(0);
})();