安徽工业大学教务系统计算GPA

try to take over the world!

// ==UserScript==
// @name         安徽工业大学教务系统计算GPA
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       Z
// @match        http://jwxt.ahut.edu.cn/jsxsd/kscj/cjcx_list
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    var mytable=document.querySelector("#dataList")
    if(mytable && mytable.rows[1].cells[0].innerText!="未查询到数据"){
        var sumCredits=0//定义总学分
        var totalScore=0//定义总成绩
        for (var i=1;i<mytable.rows.length;i++){
            if(!isNaN(parseFloat(mytable.rows[i].cells[6].innerText))){
                sumCredits+=parseFloat(mytable.rows[i].cells[8].innerText)
                totalScore+=parseFloat(mytable.rows[i].cells[8].innerText)*parseFloat(mytable.rows[i].cells[6].innerText)}}
    var gpa= totalScore/sumCredits
    alert("您的平均学分绩是"+gpa.toFixed(2))}
})();