Calculates the Letter Grade for Canvas
< 脚本Canvas Grade Calculator的反馈
Revised and Simplified Code
Added another Canvas URL to match
Works on all grade pages
Changed the method of firing the script
// ==UserScript== // @name Canvas Grade Calculator // @namespace 0612 // @version 1.6 // @description Calculates the Letter Grade for Canvas // @author SaturnKai // @match http*://*.instructure.com/* // @match http*://*.canvas.*.edu/* // @run-at document-end // @grant none // ==/UserScript== function getLetterGrade(percent) { let grade = percent.match(/\d+\.?\d+/)?.[0]; if (!grade || percent.includes("(")) { return ""; } if (grade >= 90) { return " (A)"; } else if (grade >= 80) { return " (B)"; } else if (grade >= 70) { return " (C)"; } else if (grade >= 60) { return " (D)"; } else if (grade < 60) { return " (F)"; } else { return ""; } } function addLetterGrade(element) { element.innerText += getLetterGrade(element.innerText); } function main() { document.querySelectorAll("td.percent").forEach(addLetterGrade); document.querySelectorAll(".final_grade .grade").forEach(addLetterGrade); } if (document.readyState === "complete" || document.readyState === "interactive") { main(); } else { window.addEventListener("DOMContentLoaded", () => { main(); }); }
登录以发表回复。
Revised and Simplified Code
Added another Canvas URL to match
Works on all grade pages
Changed the method of firing the script