From 54fa2cc4a25c8fe18df1838a97a6500a838c20db Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 5 Jan 2023 09:01:46 -0800 Subject: [PATCH] Fixed possible score null In a recent update Canvas changed how assignment scores are displayed, breaking the extension. This push should fix that bug. --- src/getAssignments.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/getAssignments.ts b/src/getAssignments.ts index 9c47ed3..8fbc114 100644 --- a/src/getAssignments.ts +++ b/src/getAssignments.ts @@ -59,12 +59,13 @@ export function getAssignments(): Assignment[] { // Get the assignment average score const average: number = parseFloat(scoreDetails?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[0].getElementsByTagName('td')[0].innerText?.trim().split('\n')[1].trim() || '0'); - // Get the assignment possible score (total points) - const possible: number = parseFloat(assignment.querySelector('.possible')?.textContent?.trim() || '0'); - let score: number = 0; // Handle pass/fail assignments const gradeElement = assignment.querySelector('.grade'); + + // Get the possible score + const possible: number = parseFloat(gradeElement?.nextElementSibling?.textContent?.split('/')[1].trim() || '0'); + const gradeIcon = gradeElement?.getElementsByTagName('i')[0]; if (gradeIcon && gradeIcon.classList.contains('icon-check')) { score = possible;