masakichi
7/17/2014 - 9:17 AM

show GPA online.(designed for NJTech students)

show GPA online.(designed for NJTech students)

// ==UserScript==
// @name       online_GPA
// @version    0.1
// @description  show GPA online.
// @include      http://202.119.248.199/xscjcx_dq.aspx?xh=*
// @copyright  2014+, Gimo
// ==/UserScript==
 
function get_point(str){
    if(str=="优秀") return 4.5;
    if(str=="良好") return 3.5;
    if(str=="中等") return 2.5;
    if(str=="及格") return 1.5;
    if(str=="不及格") return 0;
    else return (parseFloat(str)-50)/10.0;
}
 
function show_GPA(){
    var table = document.getElementById("DataGrid1").rows;
    sum = 0
    sum_credit = 0
    for (var i=1; i<table.length; i++)
    {
        if(table[i].cells[4].innerHTML!="全校限选课" && table[i].cells[4].innerHTML!="公共选修课")
        {
            sum_credit += parseFloat(table[i].cells[6].innerHTML)
            
            sum += parseFloat(table[i].cells[6].innerHTML)*get_point(table[i].cells[7].innerHTML);
            
        }
    }
    alert(sum/sum_credit)
}
 
show_GPA()