Skip to content

Commit

Permalink
Version 6.4 - The convenience update!
Browse files Browse the repository at this point in the history
Version 6.4 changes & additions:
 - Added right-click to open in new tab feature
 - Overall grades available on the grades tab
 - Grades list grabs from grades tab instead of each classes' tab
 - Added click anywhere to close & auto-temp-save on background set tab
 - Fixed mastery grade average text
 - Cleaned up top bar menus
 - Fixed unintentional italicizing bug
 - Removed unnecessary innerHTML writes
 - Labeled console outputs

Thank you to everyone for using!
  • Loading branch information
N0madical committed Dec 8, 2023
1 parent d857f99 commit e5edb1b
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 115 deletions.
18 changes: 16 additions & 2 deletions extention/globalFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ function browserStorage(name, storageType, defaultValue = "[]", ...onCompleteFun
}
}

function openLink(link) {
window.open(link, "_self")
function openLink(link, newtab=false) {
if(!newtab) {
window.open(link, "_self")
} else {
window.open(link)
}

}

function addEventListeners(object) {
Expand All @@ -93,6 +98,15 @@ function addEventListeners(object) {
buttonfunctions[funcname].apply(null, funcargs)
});
}
if(clickable[b].hasAttribute("onrightclickevent")) {
let func = clickable[b].getAttribute("onrightclickevent");
let funcname = func.substring(0,func.indexOf("("));
let funcargs = JSON.parse(("[" + func.substring(func.indexOf("(")+1,func.length-1) + "]").replaceAll('\'', '\"')) //.split(/(?<=['|"]), (?=['|"])/);
clickable[b].addEventListener("contextmenu", (e) => {
buttonfunctions[funcname].apply(null, funcargs)
e.preventDefault()
});
}
}
} catch (error) {
console.error(`Error setting event listeners: ${error}`)
Expand Down
15 changes: 12 additions & 3 deletions extention/globalIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (typeof browser !== "undefined") {


//########################################################
//Removing unwanted UI elements
//Removing unwanted UI elements & Fixing Others
//########################################################

buttons = document.getElementsByClassName("_13cCs _2M5aC _24avl _3ghFm _3LeCL _31GLY _9GDcm _1D8fw")
Expand All @@ -28,6 +28,15 @@ if(document.getElementById("app-run-5922356464") != null) {
document.getElementById("app-run-5922356464").remove()
}

headerbuttons = document.getElementById("header").querySelector("nav").querySelectorAll("button")
for(let i = 0; i < headerbuttons.length; i++) {
if(headerbuttons[i].innerHTML == "Grades") {
headerbuttons[i].parentElement.innerHTML = `
<a class="_13cCs _2M5aC _24avl _3ghFm _3LeCL _31GLY _9GDcm _1D8fw util-height-six-3PHnk util-pds-icon-default-2kZM7 _1SIMq _2kpZl _3OAXJ _3_bfp _3v0y7 _2s0LQ util-line-height-six-3lFgd util-text-decoration-none-1n0lI Header-header-button-active-state-3AvBm Header-header-button-1EE8Y sExtlink-processed" href="/grades/grades">Grades</a>
`
}
}


//########################################################
//Checking for updates
Expand Down Expand Up @@ -58,8 +67,8 @@ function onGetNextCheck() {
}
nextCheck.value = Date.now() + 86400000
nextCheck.set()
console.info("Current version is", vnumber, "and most recent Git version is", chrome.runtime.getManifest().version)
console.info("Powerology: Current version is", vnumber, "and most recent Git version is", chrome.runtime.getManifest().version)
}
}
console.info("It is currently", Date.now(), "ms, app will check for update at", nextCheck.value, "ms.")
console.info("Powerology: It is currently", Date.now(), "ms, app will check for update at", nextCheck.value, "ms.")
}
76 changes: 76 additions & 0 deletions extention/gradeOverview/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
document.getElementById("past-selector").innerHTML += `<p style="float: right; margin-top: 5px;">Overall Grade (Including Executive Functions)</p>`

let classeslist = document.getElementById("main-inner").getElementsByClassName("gradebook-course")
for(let i = 0; i < classeslist.length; i++) {
grades = classeslist[i].getElementsByClassName("item-row")
let avgvar = 0
let count = 0
let avg = "Not Avaliable"
for(let j = 0; j < grades.length; j++) {
if(grades[j].getElementsByClassName("rounded-grade").length > 0) {
avgvar += parseFloat(grades[j].getElementsByClassName("rounded-grade")[0].innerHTML)
count++
}
}

if((avgvar/count) <= 100) {
avg = (avgvar/count).toFixed(1)
}

let color = "gray"
if(avg >= 4.0 && avg <= 5.0) {
color = "green"
} else if (avg >= 3.5 && avg < 4.0) {
color = "gold"
} else if (avg >= 0.0 && avg < 3.5) {
color = "crimson"
}

classeslist[i].getElementsByClassName("gradebook-course-title")[0].innerHTML += `<div style="width: 20px; height: 20px; float:right; background-color: ${color}; margin-left: 10px"></div><h3 style="float: right; line-height: 9px">${avg}</h3>`
}


//########################################################
//Saving Grades
//########################################################

pastGrades = new browserStorage("pastGrades", "local", [], definePastGrades)
pastGrades.get()

function definePastGrades() {;
let gradelist = document.getElementsByClassName("item-row")
for(i = 0; i < gradelist.length; i++) {
if(gradelist[i].getElementsByClassName("rounded-grade")[0]) {
let name = gradelist[i].getElementsByClassName("title")[0].textContent.substring(0,gradelist[i].getElementsByClassName("title")[0].textContent.indexOf("assignment"))
let link = gradelist[i].getElementsByClassName("title")[0].children[0].href
let duedatems
if(gradelist[i].getElementsByClassName("due-date")[0]) {
let duedate = gradelist[i].getElementsByClassName("due-date")[0].textContent.substring(4)
duedatems = Date.parse(duedate.substring(0,duedate.indexOf(" ")))
} else {
duedatems = parseInt(Date.now())-604800000
}
let grade = parseFloat(gradelist[i].getElementsByClassName("rounded-grade")[0].innerHTML).toFixed(1)

let match2 = false
for(let h=0; h < pastGrades.value.length; h++) {
if(pastGrades.value[h][1][0] == name) {
if(pastGrades.value[h][1][1] != grade) {
console.info("Powerology: Found same name with different grade:", name, ":", pastGrades.value[h][1][1], "=>", grade)
pastGrades.value.splice(h,1)
} else {
match2 = true;
}
}
}
if(!match2) {
pastGrades.value.push([[duedatems],[name,grade,link]])
pastGrades.value.sort((a, b) => a[0] - b[0])
// browser.storage.local.getBytesInUse("pastGrades").then(printBytes, onError)
// function printBytes(input) {console.debug("Storage used:", input)}
}
}
}
pastGrades.set()
}

82 changes: 41 additions & 41 deletions extention/gradePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let grades = document.getElementsByClassName("rounded-grade")
let total = 0
let divby = 0
for(let i = 0; i < grades.length; i++) {
if(!grades[i].innerHTML.includes("%") && (grades[i].innerHTML <= 5 && grades[i].innerHTML >= 0)) {
if(!grades[i].innerHTML.includes("%") && (grades[i].innerHTML <= 10 && grades[i].innerHTML >= 0)) {
total += parseFloat(grades[i].innerHTML)
divby++
}
Expand All @@ -25,7 +25,7 @@ if(document.getElementById("averageBox") == null) {
`)
}

document.getElementById("overallgrade").innerHTML = avgGrade
document.getElementById("overallgrade").textContent = avgGrade


//########################################################
Expand All @@ -34,45 +34,45 @@ document.getElementById("overallgrade").innerHTML = avgGrade

//pastGrades = []
// browser.storage.local.set({pastGrades})
pastGrades = new browserStorage("pastGrades", "local", [], definePastGrades)
pastGrades.get()
// pastGrades = new browserStorage("pastGrades", "local", [], definePastGrades)
// pastGrades.get()

function definePastGrades() {;
let gradelist = document.getElementsByClassName("item-row")
for(i = 0; i < gradelist.length; i++) {
if(gradelist[i].getElementsByClassName("rounded-grade")[0]) {
console.debug(gradelist[i])
let name = gradelist[i].getElementsByClassName("title")[0].textContent.substring(0,gradelist[i].getElementsByClassName("title")[0].textContent.indexOf("assignment"))
let link = gradelist[i].getElementsByClassName("title")[0].children[0].href
let duedatems
if(gradelist[i].getElementsByClassName("due-date")[0]) {
let duedate = gradelist[i].getElementsByClassName("due-date")[0].textContent.substring(4)
duedatems = Date.parse(duedate.substring(0,duedate.indexOf(" ")))
} else {
duedatems = parseInt(Date.now())-604800000
}
let grade = parseFloat(gradelist[i].getElementsByClassName("rounded-grade")[0].innerHTML).toFixed(1)
// function definePastGrades() {;
// let gradelist = document.getElementsByClassName("item-row")
// for(i = 0; i < gradelist.length; i++) {
// if(gradelist[i].getElementsByClassName("rounded-grade")[0]) {
// console.debug(gradelist[i])
// let name = gradelist[i].getElementsByClassName("title")[0].textContent.substring(0,gradelist[i].getElementsByClassName("title")[0].textContent.indexOf("assignment"))
// let link = gradelist[i].getElementsByClassName("title")[0].children[0].href
// let duedatems
// if(gradelist[i].getElementsByClassName("due-date")[0]) {
// let duedate = gradelist[i].getElementsByClassName("due-date")[0].textContent.substring(4)
// duedatems = Date.parse(duedate.substring(0,duedate.indexOf(" ")))
// } else {
// duedatems = parseInt(Date.now())-604800000
// }
// let grade = parseFloat(gradelist[i].getElementsByClassName("rounded-grade")[0].innerHTML).toFixed(1)

let match2 = false
for(let h=0; h < pastGrades.value.length; h++) {
if(pastGrades.value[h][1][0] == name) {
if(pastGrades.value[h][1][1] != grade) {
console.info("Found same name with different grade:", name, ":", pastGrades.value[h][1][1], "=>", grade)
pastGrades.value.splice(h,1)
} else {
match2 = true;
}
}
}
if(!match2) {
pastGrades.value.push([[duedatems],[name,grade,link]])
pastGrades.value.sort((a, b) => a[0] - b[0])
console.debug(`${pastGrades.value}`)
// browser.storage.local.getBytesInUse("pastGrades").then(printBytes, onError)
// function printBytes(input) {console.debug("Storage used:", input)}
pastGrades.set()
}
}
}
}
// let match2 = false
// for(let h=0; h < pastGrades.value.length; h++) {
// if(pastGrades.value[h][1][0] == name) {
// if(pastGrades.value[h][1][1] != grade) {
// console.info("Found same name with different grade:", name, ":", pastGrades.value[h][1][1], "=>", grade)
// pastGrades.value.splice(h,1)
// } else {
// match2 = true;
// }
// }
// }
// if(!match2) {
// pastGrades.value.push([[duedatems],[name,grade,link]])
// pastGrades.value.sort((a, b) => a[0] - b[0])
// console.debug(`${pastGrades.value}`)
// // browser.storage.local.getBytesInUse("pastGrades").then(printBytes, onError)
// // function printBytes(input) {console.debug("Storage used:", input)}
// pastGrades.set()
// }
// }
// }
// }

Loading

0 comments on commit e5edb1b

Please sign in to comment.