|
| 1 | +/** |
| 2 | + * |
| 3 | + * @copyright Copyright (c) 2023-2024 Anvay Mathur <[email protected]> |
| 4 | + * |
| 5 | + * @author Anvay Mathur <[email protected]> |
| 6 | + * |
| 7 | + * @license GNU AGPL-3.0-only |
| 8 | + * |
| 9 | + * SAS Powerschool Enhancement Suite - A browser extension to improve the experience of SAS Powerschool. |
| 10 | + * |
| 11 | + * This program is free software: you can redistribute it and/or modify |
| 12 | + * it under the terms of the GNU Affero General Public License as |
| 13 | + * published by the Free Software Foundation, version 3. |
| 14 | + * |
| 15 | + * This program is distributed in the hope that it will be useful, |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | + * GNU Affero General Public License for more details. |
| 19 | + * |
| 20 | + * You should have received a copy of the GNU Affero General Public License |
| 21 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +import { Class, ClassManager } from "../../models/classes"; |
| 26 | +import GPA from "./GPA.svelte"; |
| 27 | +import { listOfGrades, type Grade } from "../../models/grades"; |
| 28 | + |
| 29 | +const classManager = new ClassManager([]); |
| 30 | + |
| 31 | +const rows = document.querySelectorAll(".linkDescList.grid > tbody > tr.center:not(.th2)"); |
| 32 | + |
| 33 | +for (const row of rows) { |
| 34 | + const nameEle = row.querySelector("td:nth-child(2)"); |
| 35 | + const s1GradeEle = row.querySelector("td:nth-child(3)"); |
| 36 | + const s2GradeEle = row.querySelector("td:nth-child(4)"); |
| 37 | + |
| 38 | + if (!nameEle || !s1GradeEle || !s2GradeEle) continue; |
| 39 | + |
| 40 | + const name = nameEle.firstChild?.textContent?.trim(); |
| 41 | + if (!name) continue; |
| 42 | + |
| 43 | + let s1Grade: string | null = s1GradeEle.textContent?.trim()!; |
| 44 | + if (!s1Grade) continue; |
| 45 | + if (!listOfGrades.includes(s1Grade as Grade)) s1Grade = null; |
| 46 | + |
| 47 | + let s2Grade: string | null = s2GradeEle.textContent?.trim()!; |
| 48 | + if (!s2Grade) continue; |
| 49 | + if (!listOfGrades.includes(s2Grade as Grade)) s2Grade = null; |
| 50 | + |
| 51 | + if (!s1Grade && !s2Grade) continue; |
| 52 | + classManager.addClass(new Class(name, { s1: s1Grade as Grade | null, s2: s2Grade as Grade | null })) |
| 53 | +} |
| 54 | + |
| 55 | + |
| 56 | +console.log(classManager); |
| 57 | +const target = document.createElement("div"); |
| 58 | +document |
| 59 | + .querySelector("#content-main > .box-round") |
| 60 | + ?.insertBefore(target, document.querySelector("#quickLookup")); |
| 61 | + |
| 62 | +new GPA({ target: target as Element, props: { classManager: classManager } }); |
0 commit comments