// ==UserScript==
// @name cug教务系统学分计算器
// @namespace http://202.114.207.126/jwglxt/xsxy/
// @version 1.1
// @description 排除通选学分的绩点计算
// @author Chunibyo
// @match http://202.114.207.126/jwglxt/xsxy/*
// @grant none
// @downloadURL none
// ==/UserScript==
jQuery(function($){
'use strict';
$(function () {
// 总的学分和sum(credit * grade)
let sum_gained_credit = 0
let sum_credit = 0
let tmp1, tmp2
// 第一栏的课程
$("div.position_r > ul.treeview > li:first li tbody > tr").each(function (index, item) {
if (($(item).find("td:first > div").hasClass("tjxk4")) === true) {
tmp1 = parseFloat($(item).find("td[name = 'xf']").html()) // 这门课的学分
tmp2 = parseFloat($(item).find("td:nth-child(12)").html())
if (isNaN(tmp1) || isNaN(tmp2)) tmp1 = 0, tmp2 = 0
sum_credit += tmp1 // 选课的总学分
sum_gained_credit += tmp1 * tmp2 // 获得的总学分
}
})
// 展示
let str1 = '除去通选的学分绩点:' +
(sum_gained_credit / sum_credit).toFixed(3) +
''
$("#alertBox br:first").after(str1)
// 其他课程(第二栏)
$("#kcxxqtkcxfyq tbody > tr").each(function (index, item) {
tmp1 = parseFloat($(item).find("td[name = 'xf']").html()) // 这门课的学分
tmp2 = parseFloat($(item).find("td:nth-child(12)").html())
if (isNaN(tmp1) || isNaN(tmp2)) tmp1 = 0, tmp2 = 0
sum_credit += tmp1 // 选课的总学分
sum_gained_credit += tmp1 * tmp2 // 获得的总学分
})
// 展示
let str2 = ' 供各位校验的计算了通选的GPA:' +
(sum_gained_credit / sum_credit).toFixed(3) +
'
'
$("#alertBox > font:nth-child(4)").after(str2)
})
});