-
Notifications
You must be signed in to change notification settings - Fork 0
/
detailedGrades.js
107 lines (97 loc) · 4.42 KB
/
detailedGrades.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// ==UserScript==
// @name XJTU ehall 成绩查询增强
// @namespace https://github.com/MiracleHYH/Enhance-XJTU-EHALL
// @version 0.2
// @description 增加显示成绩详情以及排名信息
// @author Miracle
// @match http://ehall.xjtu.edu.cn/new/thirdAppIndexShell.html
// @match http://ehall.xjtu.edu.cn/jwapp/sys/cjcx/*default/index.do*
// @icon https://www.google.com/s2/favicons?sz=64&domain=www.xjtu.edu.cn
// @grant none
// @run-at document-end
// @license GNU GPLv3
// ==/UserScript==
var $, grades = {};
function query_pm(info, data) {
let httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'http://ehall.xjtu.edu.cn/jwapp/sys/cjcx/modules/cjcx/jxbxspmcx.do', true);
httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
httpRequest.send(data);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
let res = JSON.parse(httpRequest.responseText).datas.jxbxspmcx.rows[0];
info += `排名:${res.PM}/${res.ZRS}`;
alert(info);
}
};
}
function query() {
let courseId = $("#queryInfo_courseId").val();
//console.log(grades[courseId])
if (courseId.length == 0 || typeof(grades[courseId]) == 'undefined') {
alert("课程号错误");
return;
}
//console.log(courseId);
//console.log(grades[courseId]);
let info = ""
let sycj = grades[courseId].SYCJ_DISPLAY.length>0 ? grades[courseId].SYCJ_DISPLAY : grades[courseId].SYCJ;
if (sycj != null) info += `实验成绩:${sycj}\n`;
let pscj = grades[courseId].PSCJ;
if (pscj != null) info += `平时成绩:${pscj} --- ${grades[courseId].PSCJXS}%\n`;
let qzcj = grades[courseId].QZCJ;
if (qzcj != null) info += `期中成绩:${qzcj} --- ${grades[courseId].QZCJXS}%\n`;
let qmcj = grades[courseId].QMCJ;
if (qmcj != null) info += `期末成绩:${qmcj} --- ${grades[courseId].QMCJXS}%\n`;
for (let i = 1; i <= 10; ++ i) {
let qtcj = grades[courseId][`QTCJ${i}_DISPLAY`].length>0 ? grades[courseId][`QTCJ${i}_DISPLAY`] : grades[courseId][`QTCJ${i}`];
if (qtcj != null) info += `其他成绩${i}:${qtcj}\n`;
}
info += `总成绩:${grades[courseId].ZCJ}\n`;
query_pm(info, `JXBID=${grades[courseId].JXBID}&XNXQDM=${grades[courseId].XNXQDM}`);
}
function addQuery() {
setTimeout(function(){
$("article>section>div#cjcx-index-search").after($(
'<div style="position: relative; z-index: 358;"><div class="bh-advancedQuery bh-mb-16" style="overflow: hidden;"><div class="bh-advancedQuery-quick"><div class="bh-advancedQuery-inputGroup bh-clearfix" style="padding-bottom: 8px;background: #fff;"><div class="bh-advancedQuery-quick-search-wrap"><input id="queryInfo_courseId" type="text" class="bh-form-control" placeholder="请输入课程号查询成绩详情"><i class="iconfont icon-search" style="position: absolute;left: 6px;top: 6px;"></i></div><a id="queryInfo" class="bh-btn bh-btn bh-btn-primary bh-btn-small">成绩详情查询</a></div></div></div></div>'
));
$("#queryInfo").bind("click", query);
}, 500);
}
function redirectToReal() {
let url = document.getElementById("thirdpartyFrame").src;
if (typeof(url) == 'undefined') {
setTimeout(function(){redirectToReal()}, 500);
return;
}
location.replace(url);
}
function main() {
if ($("div.bh-headerBar-title").length == 0) {
setTimeout(function(){main()}, 500);
return;
}
$("div.bh-headerBar-title").text("成绩查询 增强版");
$("div.bh-headerBar-nav-item.bh-active").bind('click', addQuery);
addQuery()
// 获取成绩
let httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'http://ehall.xjtu.edu.cn/jwapp/sys/cjcx/modules/cjcx/xscjcx.do', true);
httpRequest.send();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
JSON.parse(httpRequest.responseText).datas.xscjcx.rows.forEach((item) => {
grades[item.KCH] = item;
});
}
};
}
(function() {
'use strict';
if (window.location.href == 'http://ehall.xjtu.edu.cn/new/thirdAppIndexShell.html') {
setTimeout(function(){redirectToReal()}, 0);
} else {
$ = window.$;
setTimeout(function(){main()}, 0);
}
})();