计算总学分

此脚本用来计算教务管理系统中当前学生的已经获得的所有学分

目前為 2021-12-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name         计算总学分
// @namespace    http://tampermonkey.net/
// @version      0.5
// @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';
function expand() {
    /**
    * 一键展开
    */
    var expandList = document.querySelectorAll(".expandable-hitarea")
    for (var i = 0; i < expandList.length; i++) {
        var xf = expandList[i].click()
    }
}
function expandAll() {
    /**
    * 一键展开(全部)
    */
    expand()
    expandAndCollapMore()
}
function collap() {
    /**
    * 一键收拢
    */
    var collapList = document.querySelectorAll(".collapsable-hitarea")
    for (var i = 0; i < collapList.length; i++) {
        var xf = collapList[i].click()
    }
    
}

function expandAndCollapMore() {
    /**
    * 展开/收拢下拉列表
    */
    var moreList = document.querySelectorAll(".more")
    for (var i = 0; i < moreList.length; i++) {
        moreList[i].click()
    }
}

collap()

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 sumScore = majorScoreSum + otherScoreSum
var alertBox = document.querySelector("#alertBox")
var innerHtmlStr = `
 <div style="position: fixed; top:200px; right: 200px; z-index:999;" id="change">
    <table  cellspacing="1" cellpadding="4" border="0" align="center" >
            <tr>
                <td align="center" colspan="2" height="30px" style="font-size:18px"><b>学分情况</b></td>
            </tr>
            <tr style="background:#288ace55; color:white;border-radius: 60px; " height="30px">
                <th align="center" style="padding:15px 10px 15px 50px">主修课程学分</th>
                <td align="center">` + majorScoreSum + `</td>
            </tr>
            <tr style="background:#5500ff55;color:white" >
                <th align="center" style="padding:15px 10px 15px 50px">其他课程学分</th>
                <td align="center">` + otherScoreSum + `</td>
            </tr>
            <tr style="background:#ffea0055;color: black">
                <th align="center" style="padding:15px 10px 15px 50px">综合学分总和</th>
                <td align="center" style="color:red"><b>` + sumScore + `</b></td>
            </tr>
            <tr>
                <td >
                    <a onclick="expand()" style="display:block;padding:15px 10px 15px 50px; cursor:pointer" >一键展开</a>
                </td>
                <td >
                    <a onclick="expandAll()" style="display:block;padding:15px 10px 15px 50px; cursor:pointer;">一键展开(全部)</a>
                </td>
            </tr>
            <tr>
                <td>
                    <a onclick="expandAndCollapMore()" style="display:block;padding:15px 10px 15px 50px; cursor:pointer">下拉/上收</a>
                </td>
                <td>
                    <a onclick="collap()" style="display:block;padding:15px 10px 15px 50px; cursor:pointer">一键收拢(全部)</a>
                </td>
            </tr>
        </table>
 </div>
`
alertBox.innerHTML += innerHtmlStr

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址