Greasy Fork

Greasy Fork is available in English.

Hdu教务系统已选学分统计

统计hdu教务系统里当前界面的已选学分的辅助工具

当前为 2020-02-25 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hdu教务系统已选学分统计
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  统计hdu教务系统里当前界面的已选学分的辅助工具
// @author       In_The_Wind
// @include      http://jxgl.hdu.edu.cn/*
// @grant        none
//@supportURL  [email protected]
// ==/UserScript==
/*jshint esversion: 6 */
var calCredit = function () {
    'use strict';
    // Your code here...
    let credit = getNowPageCredit();
    setShownCredit(credit);

};
var getNowPageCredit = function () {
    let credit = 0;
    let allclass = document.querySelectorAll("#kcmcgrid > tbody >tr");
    for (let i = 1; i <= allclass.length - 2; ++i) {
        //注意这个table,i从1开始,到allclass.length-2结束,这里i=0是表头,表尾length-1这里表示table的页面跳转,坑了很长时间才发现
        let selected = allclass[i].cells[8].innerText;
        if (selected === "已选") {
            credit = credit + parseFloat(allclass[i].children[4].innerText)
        }
    }
    return credit;
};
var setShownCredit = function (totalCredit) {
    let newtext = document.querySelector("#Table1 > tbody > tr.trtitle > td:nth-child(5)");
    newtext.innerText = "当前界面已选学分";
    let position = document.querySelector("#Table1 > tbody > tr:nth-child(2) > td:nth-child(5)");
    position.innerText = totalCredit;
};
setTimeout(calCredit,1000);