-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (25 loc) · 785 Bytes
/
script.js
File metadata and controls
28 lines (25 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const transcriptRows = document.querySelectorAll(
"#ctl00_mainContent_divGrade > table > tbody > tr"
);
const transcript = [...transcriptRows]
.map((row) => ({
credit: +row.querySelectorAll("td")[7]?.innerText,
grade: +row.querySelectorAll("td")[8]?.innerText,
}))
.filter((row) => row && row.grade > 0 && row.credit > 0)
.reduce(
(acc, row) => {
acc.totalCredit += row.credit;
acc.totalScore += row.credit * row.grade;
return acc;
},
{
totalCredit: 0,
totalScore: 0,
}
);
const currentGpa = (transcript.totalScore / transcript.totalCredit).toFixed(2);
// Write GPA to page
document.getElementById(
"ctl00_mainContent_lblRollNumber"
).innerHTML += ` - <span class="label label-success">GPA: ${currentGpa}</span>`;