NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name DTU grade average // @namespace dtu // @description Displays grade average on DTU Inside // @include https://cn.inside.dtu.dk/cnnet/Grades/Grades.aspx // @version 1.1 // @grant none // ==/UserScript== var table = document.getElementsByClassName('gradesList'); var td = table[0].rows[0].insertCell(); td.appendChild(document.createTextNode('Rolling average')); var totalGrades = 0; var totalWeightedGrades = 0; var totalWeight = 0; var totalAmount = 0; for (var i = table[0].rows.length - 1; i > 0; i--) { var row = table[0].rows[i]; var grade = row.cells[2].innerText; var weight = row.cells[3].innerText; var gradeInt = parseInt(grade.substr(0, grade.indexOf('(') - 1)); if (!isNaN(gradeInt)) { var weightFloat = parseFloat(weight); totalGrades += gradeInt; totalWeightedGrades += gradeInt * weightFloat; totalWeight += weightFloat; totalAmount++; } var td = table[0].rows[i].insertCell(); td.appendChild(document.createTextNode(Math.round(totalWeightedGrades / totalWeight * 100) / 100)); } var tr = table[0].insertRow(); var td = tr.insertCell(); td.appendChild(document.createTextNode('Average')); var td = tr.insertCell(); td.appendChild(document.createTextNode(Math.round(totalGrades / totalAmount * 100) / 100)); var tr = table[0].insertRow(); var td = tr.insertCell(); td.appendChild(document.createTextNode('Weighted average')); var td = tr.insertCell(); td.appendChild(document.createTextNode(Math.round(totalWeightedGrades / totalWeight * 100) / 100));