Greasy Fork

Greasy Fork is available in English.

Hdu课程总学分统计

在"学生选课情况查询"页面统计当前学期已选课程学分

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hdu课程总学分统计
// @namespace    http://tampermonkey.net/
// @version      1.00
// @description  在"学生选课情况查询"页面统计当前学期已选课程学分
// @author       litStronger
// @include      http://jxgl.hdu.edu.cn/*
// @grant        none

// ==/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) {
        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);
var showTotalCredit = function () {
    var tbodyp = document.getElementById("DBGrid");

    var tbody = tbodyp.children[0];
    var tbodyChildren = tbody.children;
    var sum = 0;
    for (let i = 1; i < tbodyChildren.length; ++i) {
        sum += parseFloat(tbodyChildren[i].children[5].innerText);
    }

    console.log("tool box");

    let toolBox = document.getElementsByClassName("toolbox")[0]
    console.log("tool box");
    var toolBoxMsg = document.getElementsByClassName("toolbox")[0].innerHTML;

    console.log(toolBox);
        console.log(toolBoxMsg);

    toolBox.innerHTML = toolBoxMsg+"<p>该学期已选学分"+sum+"</p>"
};

setTimeout(showTotalCredit, 1000);