Skip to content

Instantly share code, notes, and snippets.

@eiiot
Created September 16, 2021 01:03
Show Gist options
  • Select an option

  • Save eiiot/7ef406b22f68e4dfbd57c8596f895507 to your computer and use it in GitHub Desktop.

Select an option

Save eiiot/7ef406b22f68e4dfbd57c8596f895507 to your computer and use it in GitHub Desktop.
Tampermonkey - Infinite Campus Grade Percents
// ==UserScript==
// @name Infinute Campus Grade Percent Calculator
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add percentages to infinute campus
// @author eiiot
// @match https://*.infinitecampus.org/*
// @icon https://infinitecampus.org/favicon.ico
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
console.log('script init');
function evil(fn) {
return new Function('return ' + fn)();
};
var fireOnHashChangesToo = true;
var pageURLCheckTimer = setInterval (
function () {
if (this.lastPathStr !== location.pathname
|| this.lastQueryStr !== location.search
|| (fireOnHashChangesToo && this.lastHashStr !== location.hash)
) {
this.lastPathStr = location.pathname;
this.lastQueryStr = location.search;
this.lastHashStr = location.hash;
gmMain ();
}
}
, 111
);
function gmMain () {
clearInterval(checkExist);
var checkExist = setInterval(function() {
try {
if (typeof document.getElementById('main-workspace').contentDocument.getElementsByClassName('totals__row--task')[0].children[0].innerHTML !== 'undefined') {
clearInterval(checkExist);
var grade = document.getElementById('main-workspace').contentDocument.getElementsByClassName('totals__row--task')[0].children[0];
var gradeValue = grade.innerHTML.replace(/ /g, "");
grade.innerHTML = ` ${gradeValue} (${(evil(gradeValue)*100).toFixed(2)}%) `
}
} catch (e) {
return;
};
}, 100);
};
})();
@eiiot
Copy link
Author

eiiot commented Sep 16, 2021

Installation Instructions

  1. Install the tampermonkey extension
  2. Click the Raw button on the top of this gist!

Created by Eliot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment