Greasy Fork is available in English.
优化果壳选课界面
当前为
// ==UserScript==
// @name 果壳选课优化
// @namespace https://jwxk.ucas.ac.cn/
// @version 0.2
// @description 优化果壳选课界面
// @author You
// @include *//jwxk.ucas.ac.cn/courseManage/*
// @include https://jwxk.ucas.ac.cn/score/yjs/all
// @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 showScore() {
let lesson_list = {}
let score_list = []
fetch('https://jwxk.ucas.ac.cn/score/yjs/all.json')
.then(response => response.text())
.then(text => {
lesson_list = eval('(' + text + ')').list
for (let lesson of lesson_list) {
score_list.push(lesson.score)
}
let idx = 1
while (true) {
let grid = document.querySelector("#main-content > div > div.m-cbox.m-lgray > div.mc-body > table > tbody > tr:nth-child(" + idx + ") > td:nth-child(3)")
if (grid == null) {
break
}
grid.innerHTML = score_list[idx - 1]
idx += 1
}
})
.catch(error => console.error(error));
}
function start() {
console.log('start:果壳选课优化')
let url = window.parent.location.href
hideFullCourse()
showEnglishCourseButton()
showCourseCount()
if (url === 'https://jwxk.ucas.ac.cn/score/yjs/all') {
showScore()
}
}
setTimeout(start, 100)
})();