Greasy Fork

Greasy Fork is available in English.

果壳选课优化

优化果壳选课界面

当前为 2022-08-31 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         果壳选课优化
// @namespace    https://jwxk.ucas.ac.cn/
// @version      0.1
// @description  优化果壳选课界面
// @author       You
// @include        *//jwxk.ucas.ac.cn/courseManage/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ucas.ac.cn
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function hideFullCourse() {
        let body = document.querySelector("#regfrm > table > tbody")
        if (body === null) {
            return
        }
        for (let i = 0; i < body.childElementCount; i++) {
            let node = body.children[i]
            if (node.firstElementChild.firstElementChild.disabled) {
                node.style.display = "none"
            }
        }
    }

    function showEnglishCourseButton() {
        let box = document.querySelector("#regfrm2 > div:nth-child(9)")
        if (box === null) {
            return
        }
        let button = document.createElement('button')
        button.id = 'go-english-btn'
        button.innerHTML = '跳转英语课'
        button.setAttribute('class', 'btn btn-primary')
        button.setAttribute('type', 'submit')
        button.onclick = function() {
            document.querySelector("#id_915").checked = true
            document.querySelector("#regfrm2 > div:nth-child(9) > button").click()
        }
        box.appendChild(button)
    }

    function showCourseCount() {
        let body = document.querySelector("#regfrm > table > tbody")
        if (body === null) {
            return
        }
        let count = 0
        for (let i = 0; i < body.childElementCount; i++) {
            let node = body.children[i]
            if (!node.firstElementChild.firstElementChild.disabled) {
                count++
            }
        }
        let node = document.querySelector("#main-content > div > div.m-cbox.m-lgray > div.mc-body > div.alert-danger")
        node.innerHTML = node.innerHTML + '<br/>当前可选课程数量:' + count
    }

    function start() {
        console.log('start')
        hideFullCourse()
        showEnglishCourseButton()
        showCourseCount()
    }
    setTimeout(start, 100)
})();