Raw Source
onlined / METU Physics Total Grade

// ==UserScript==
// @name         METU Physics Total Grade
// @namespace    https://openuserjs.org/scripts/onlined/METU_Physics_Total_Grade
// @description  Shows total grade next to partial grades.
// @author       onlined
// @version      0.1.1
// @match        http://www.physics.metu.edu.tr/genphys/search.html
// @updateURL    https://openuserjs.org/meta/onlined/METU_Physics_Total_Grade.meta.js
// @downloadURL  https://openuserjs.org/src/scripts/username/METU_Physics_Total_Grade.user.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    var table = document.getElementsByTagName("table")[0];
    if(table.children.length == 1) 
        table = table.children[0];
    
    var trs = table.children;
    var change = false;
    var i;
    
    loop:
    for(i=0;i<trs.length;i++) {
        var tr = trs[i];
        switch(i%3) {
            case 0:
                if(tr.children[0].children[0].childNodes[0].nodeValue.trim().startsWith('PHYS')) 
                    change = true;
                else if(tr.children[0].children[0].childNodes[0].nodeValue.trim().startsWith('Your Exam Details')) 
                    break loop;
                if(change)
                    tr.children[0].setAttribute('colspan','9');
                break;
            case 1:
                var td = tr.insertCell(-1);
                td.outerHTML = '<td align="CENTER"><b>TG</b></td>';
                break;
            case 2:
                var total = 0;
                var coefficients = [0.25,0.25,0.4,0.1,1];
                var tds = tr.children;
                for(var j=2;j<tds.length-1;j++) {
                    var number = 0;
                    if(tds[j].childNodes[0].nodeValue)
                        number = parseInt(tds[j].childNodes[0].nodeValue.trim());
                    if(isNaN(number))
                        number = 0;
                    total += number * coefficients[j-2];
                }
                td = tr.insertCell(-1);
                td.outerHTML = '<td align="RIGHT">' + total.toFixed(2).toString() + '</td>';
                break;
        }
    }
    
    if(change) {
        trs[i+2].children[2].setAttribute('colspan','7');
        trs[i+3].children[1].setAttribute('colspan','7');
        trs[i+4].children[3].setAttribute('colspan','4');
    }
    // Your code here...
})();