Skip to content

Commit

Permalink
Fixed semester class gpa
Browse files Browse the repository at this point in the history
Signed-off-by: Anvay Mathur <[email protected]>
  • Loading branch information
megagames-me committed Jan 11, 2024
1 parent fbdd862 commit 657ad1e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "saspes",
"private": true,
"version": "2.0.0",
"version": "2.0.1",
"description": "SAS Powerschool Enhancement Suite",
"type": "module",
"scripts": {
Expand Down
29 changes: 20 additions & 9 deletions src/content_script/guardianHome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,37 @@ const classManager = new ClassManager([]);
const rows = document.querySelectorAll(".linkDescList.grid > tbody > tr.center:not(.th2)");



console.log("Found rows", rows);
for (const row of rows) {
const nameEle = row.querySelector("td:nth-child(2)");
const s1GradeEle = row.querySelector("td:nth-child(3) > a") as HTMLAnchorElement;
const s2GradeEle = row.querySelector("td:nth-child(4) > a");

console.log("cur", row, nameEle, s1GradeEle, s2GradeEle);


if (!nameEle || !s1GradeEle || !s2GradeEle) continue;
if (!nameEle || !(s1GradeEle || s2GradeEle)) {
console.log("Missing element on ", row, nameEle, s1GradeEle, s2GradeEle);
continue;
}

const name = nameEle.firstChild?.textContent?.trim();
if (!name) continue;
if (!name) {
console.log("No name on ", nameEle, row);
continue;
};

let s1Grade: string | null = s1GradeEle?.textContent?.trim()!;

let s1Grade: string | null = s1GradeEle.textContent?.trim()!;
if (!s1Grade) continue;
if (!listOfGrades.includes(s1Grade as Grade)) s1Grade = null;

let s2Grade: string | null = s2GradeEle.textContent?.trim()!;
if (!s2Grade) continue;
let s2Grade: string | null = s2GradeEle?.textContent?.trim()!;

if (!listOfGrades.includes(s2Grade as Grade)) s2Grade = null;

if (!s1Grade && !s2Grade) continue;
if (!s1Grade && !s2Grade) {
console.log("No grades on ", nameEle, row);
continue;
};

if (s1Grade !== null && s1Grade !== "INC" && s1GradeEle.href !== null) {
const url = new URL(s1GradeEle.href);
Expand All @@ -69,6 +78,8 @@ for (const row of rows) {
if (f !== null)
s1GradeEle.innerHTML += ` (${f.toFixed(2)})`;
})
} else {
console.log("Not finding final percent for ", nameEle, row);
}

classManager.addClass(new Class(name, { s1: s1Grade as Grade | null, s2: s2Grade as Grade | null }))
Expand Down

0 comments on commit 657ad1e

Please sign in to comment.