UCAS 国科大 选课系统看不到课程时间? 想看时间还要点开课程详情?这个脚本帮你解决!
// ==UserScript==
// @name UCAS选课显示时间
// @namespace https://github.com/tylzh97/
// @version 0.1
// @description UCAS 国科大 选课系统看不到课程时间? 想看时间还要点开课程详情?这个脚本帮你解决!
// @author Birkhoff
// @match http://jwxk.ucas.ac.cn/courseManage/selectCourse*
// @require https://unpkg.com/[email protected]/dist/jquery.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
window.onload = () => {
// console.log($);
console.log('Hello World!');
const table = document.getElementsByClassName('table table-striped table-bordered table-advance table-hover')[0];
// 处理thead
table.getElementsByTagName('thead')[0].innerHTML = '<tr><th>选课</th><th>学位</th><th>关注</th><th>课程编码</th><th>课程名称</th><th>上课时间</th><th>课时</th><th>学分</th><th>限选</th><th>已选</th><th>课程属性</th><th>授课方式</th><th>考试方式</th><th>主讲教师</th></tr>';
// 处理tbody
const tbody = table.getElementsByTagName('tbody')[0];
const tbody_tr = tbody.getElementsByTagName('tr');
// console.log(tbody_tr);
for (let i in tbody_tr) {
// console.log(tbody_tr[i]);
const tr = tbody_tr[i];
if(!tr.getElementsByTagName) {
break;
}
// console.log(tr);
const tds = tr.getElementsByTagName('td');
// console.log('tds', tds);
const aim_td = tds[4];
const insertPoint = tds[5];
$.get(aim_td.firstChild.href, (data, status) => {
// console.log(data, status);
const re = />上课时间<\/th>[\s\S]*?<td>(.+)<\/td>/ig;
let array = data.match(re);
// console.log(array);
const courseTime = RegExp.$1;
// console.log(courseTime);
const newTD = document.createElement('td');
newTD.innerHTML = '<span>' + courseTime.slice(0, courseTime.length-1) + '</span>';
tr.insertBefore(newTD, insertPoint);
})
}
}
})();
//修改于20211230,可用
(function() {
'use strict';
// Your code here...
window.onload = () => {
// console.log($);
console.log('Hello World!');
const table = document.getElementsByClassName('table table-striped table-bordered table-advance table-hover')[0];
// 处理thead
table.getElementsByTagName('thead')[0].innerHTML = '选课学位关注课程编码课程名称上课时间课时学分限选已选课程属性授课方式考试方式主讲教师';
// 处理tbody
const tbody = table.getElementsByTagName('tbody')[0];
const tbody_tr = tbody.getElementsByTagName('tr');
// console.log(tbody_tr);
for (let i in tbody_tr) {
// console.log(tbody_tr[i]);
const tr = tbody_tr[i];
if(!tr.getElementsByTagName) {
break;
}
// console.log(tr);
const tds = tr.getElementsByTagName('td');
// console.log('tds', tds);
const aim_td = tds[4];
const insertPoint = tds[5];
$.get(aim_td.firstChild.href, (data, status) => {
// console.log(data, status);
const re = />上课时间<\/th>[\s\S]*?(.+)<\/td>/ig;
let array = data.match(re);
// console.log(array);
const courseTime = RegExp.$1;
// console.log(courseTime);
const newTD = document.createElement('td');
newTD.innerHTML = '' + courseTime.slice(0, courseTime.length-1) + '';
tr.insertBefore(newTD, insertPoint);
})
}
}
})();