Bypass "Calculation of totals has been disabled" for canvas

Calculates totals when canvas doesn't want to

2022-09-13 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Bypass "Calculation of totals has been disabled" for canvas
// @namespace   https://boehs.org
// @match       https://*.instructure.com/courses/*/grades
// @grant       none
// @version     1.0.2
// @author      Evan Boehs
// @description Calculates totals when canvas doesn't want to
// @supportURL  https://gist.github.com/boehs/883fda113facb902ac440cab26b09cb9
// @license     GPL-3.0-only
// ==/UserScript==

function update() {
  let totalCurrent = 0
  let totalPossible = 0
  const assignments = document.querySelectorAll("tr.student_assignment:not(.group_total)")
  assignments.forEach(assignment => {
    const possible = Number((assignment.querySelector(".possible.points_possible").textContent || "").trim())
    const current = Number((assignment.querySelector(".assignment_score .grade").textContent.replace(/((hat-)|[^0-9-])/g,"") || "").trim())
    if (!isNaN(possible + current)) {
      totalPossible += possible
      totalCurrent += current
    }
  })
  const percent = (totalCurrent / totalPossible) * 100
  
  document.getElementById("student-grades-final").innerHTML = `${percent}% <sub>
  <span>(Bypassed)</span>
  <br/>
  <span>NOTE: This script does not support weights yet</span>
  </sub>`
}

if (document.getElementById("student-grades-final").textContent.trim() == 'Calculation of totals has been disabled') {
  const observer = new MutationObserver(update)
  
  observer.observe(document.getElementById("grades_summary"), { childList:true, subtree:true })
  
  update()
}