计算总学分

此脚本用来计算江西科技师范大学教务管理系统“学生学业情况查询”页面已经获得的学分;

当前为 2021-12-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         计算总学分
// @namespace    http://tampermonkey.net/
// @version      0.7
// @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 id="expand_" style="display:block;padding:15px 10px 15px 50px; cursor:pointer" >一键展开</a>
                </td>
                <td >
                    <a id="expandAll_" style="display:block;padding:15px 10px 15px 50px; cursor:pointer;">一键展开(全部)</a>
                </td>
            </tr>
            <tr>
                <td>
                    <a id="expandAndCollapMore_" style="display:block;padding:15px 10px 15px 50px; cursor:pointer">下拉/上收</a>
                </td>
                <td>
                    <a id="collap_" style="display:block;padding:15px 10px 15px 50px; cursor:pointer">一键收拢(全部)</a>
                </td>
            </tr>
        </table>
 </div>
`
alertBox.innerHTML += innerHtmlStr

var expand_   = document.querySelector ("#expand_");
if (expand_) {
    expand_.addEventListener ("click", expand , false);
}

var expandAll_   = document.querySelector ("#expandAll_");
if (expandAll_) {
    expandAll_.addEventListener ("click", expandAll , false);
}

var expandAndCollapMore_   = document.querySelector ("#expandAndCollapMore_");
if (expandAndCollapMore_) {
    expandAndCollapMore_.addEventListener ("click", expandAndCollapMore , false);
}

var collap_   = document.querySelector ("#collap_");
if (collap_) {
    collap_.addEventListener ("click", collap , false);
}
})();