此脚本用来计算教务管理系统中当前学生的已经获得的所有学分
当前为
// ==UserScript==
// @name 计算总学分
// @namespace http://tampermonkey.net/
// @version 0.4
// @description 此脚本用来计算教务管理系统中当前学生的已经获得的所有学分
// @author MoMingLog
// @include *//jwglxt.jxstnu.edu.cn/jwglxt/xsxy/xsxyqk_cxXsxyqkIndex.html*
// @icon https://s4.ax1x.com/2021/12/07/o6DNOH.png
// @grant none
// @license GNU GPLv3
// ==/UserScript==
(function() {
'use strict';
var majorCategories = document.querySelectorAll('#ulC66FE4774B84133BE053DE0412AC78BD>li>div.title>p.title1')
var reg = /\s获得学分:([\.\d+]*)/
var majorScoreSum = 0
for (var i = 0; i < majorCategories.length; i++) {
var majorCategorieStr = majorCategories[i].innerText
var majorScore = majorCategorieStr.match(reg)[1]
majorScoreSum += parseFloat(majorScore)
}
var otherScoreTrs = document.querySelectorAll('#tbodyqtkcxfyq tr td[name="xf"]')
var otherScoreSum = 0
for (var i2 = 0; i2 < otherScoreTrs.length; i2++) {
var otherScore = otherScoreTrs[i2].innerText
otherScoreSum += parseFloat(otherScore)
}
var res_str = '主修总学分为:' + majorScoreSum + '\n' + '其他课程总学分为:' + otherScoreSum + '\n' + '总学分为:' + (majorScoreSum + otherScoreSum)
alert(res_str)
var sumScore = majorScoreSum + otherScoreSum
var alertBox = document.querySelector("#alertBox")
var innerHtmlStr = `
<table width="20%" cellspacing="1" cellpadding="4" border="0" align="center" style="background:#288ace; color:white">
<caption><b>学分情况</b></caption>
<tr>
<th align="center">主修课程学分</th>
<td align="center">` + majorScoreSum + `</td>
</tr>
<tr bgcolor="#550000ff" >
<th align="center">其他课程学分</th>
<td align="center">` + otherScoreSum + `</td>
</tr>
<tr bgcolor="#55ffea00" style="color: black">
<th align="center">综合学分总和</th>
<td align="center" style="color:red"><b>` + sumScore + `</b></td>
</tr>
</table>
`
alertBox.innerHTML += innerHtmlStr
})();