diff --git a/extention/globalFunctions.js b/extention/globalFunctions.js index 5051762..d7696b6 100644 --- a/extention/globalFunctions.js +++ b/extention/globalFunctions.js @@ -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) { @@ -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}`) diff --git a/extention/globalIndex.js b/extention/globalIndex.js index 82e386d..b90278f 100644 --- a/extention/globalIndex.js +++ b/extention/globalIndex.js @@ -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") @@ -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 = ` + Grades + ` + } +} + //######################################################## //Checking for updates @@ -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.") } \ No newline at end of file diff --git a/extention/gradeOverview/index.js b/extention/gradeOverview/index.js new file mode 100644 index 0000000..a691a8f --- /dev/null +++ b/extention/gradeOverview/index.js @@ -0,0 +1,76 @@ + document.getElementById("past-selector").innerHTML += `

Overall Grade (Including Executive Functions)

` + + 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 += `

${avg}

` +} + + +//######################################################## + //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() +} + diff --git a/extention/gradePage/index.js b/extention/gradePage/index.js index 16d0193..e4b5191 100644 --- a/extention/gradePage/index.js +++ b/extention/gradePage/index.js @@ -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++ } @@ -25,7 +25,7 @@ if(document.getElementById("averageBox") == null) { `) } -document.getElementById("overallgrade").innerHTML = avgGrade +document.getElementById("overallgrade").textContent = avgGrade //######################################################## @@ -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() +// } +// } +// } +// } diff --git a/extention/home/functions.js b/extention/home/functions.js index 40afd50..ee86be0 100644 --- a/extention/home/functions.js +++ b/extention/home/functions.js @@ -1,7 +1,7 @@ function updateClasses() { classiteratable = 0 - console.info("Updating Class List...") - document.getElementById("classlist").innerHTML = "" + console.info("Powerology: Updating Class List...") + document.getElementById("classlist").textContent = "" for(p=0; p < classesarray.length; p++) { addClass(classesarray[p][0],classesarray[p][1]) } @@ -10,12 +10,12 @@ function updateClasses() { } function updateAssignments() { - console.info("Updating Assignment List...") + console.info("Powerology: Updating Assignment List...") asdates = [] tododates = [] iteratable = 0 - document.getElementById("assignmentlist").innerHTML = "" - document.getElementById("todolist").innerHTML = "" + document.getElementById("assignmentlist").textContent = "" + document.getElementById("todolist").textContent = "" for(p=0; p < overdueassignmentsarray.length; p++) { addAssignment("overdue",overdueassignmentsarray[p][0],"",overdueassignmentsarray[p][1]) } @@ -24,7 +24,7 @@ function updateAssignments() { } if(!document.getElementById("assignments").getElementsByClassName("errornotice")[0]) { for(let o = 0; o < errorlist.length; o++) { - document.getElementById("assignments").innerHTML += errorlist[o] + document.getElementById("assignments").insertAdjacentHTML("beforeend", errorlist[o]) } } @@ -33,8 +33,8 @@ function updateAssignments() { } function updateGradeList() { - console.info("Updating Grades List...") - document.getElementById("gradelist").innerHTML = "" + console.info("Powerology: Updating Grades List...") + document.getElementById("gradelist").textContent = "" for(p=0; p < gradesarray.length; p++) { if(gradessort[1] == "0") { addGrade(gradesarray[p][0][0],gradesarray[p][1][0],gradesarray[p][1][1],gradesarray[p][1][2],false) @@ -79,13 +79,13 @@ function addClass(name, link) { // - container.innerHTML += ` + container.insertAdjacentHTML("beforeend", ` -

${name}

- +

${name}

+ - ` + `) classiteratable++ } @@ -114,13 +114,13 @@ function addAssignment(day, name, time, link) { color = "" } - container.innerHTML += ` + container.insertAdjacentHTML("beforeend", `

${dayonly}${notday}

- ` + `) if(!checkedAssignments.value[2].includes(unEscape(name))) { asdates.push(day) @@ -142,15 +142,15 @@ function addAssignment(day, name, time, link) { textDec = "text-decoration: none;" } - container.innerHTML += ` + container.insertAdjacentHTML("beforeend", ` -

${name}

-

${time}

+

${name}

+
${time}
- ` + `) iteratable += 1 } @@ -158,11 +158,12 @@ function addAssignment(day, name, time, link) { function addGrade(date,name,grade,link,fromPast) { container = document.getElementById("gradelist") - if(grade >= 4.0) { + colorgrade = (grade > 5.0) ? (grade/20):grade + if(colorgrade >= 4.0) { color = "green" - } else if (grade >= 3.5) { + } else if (colorgrade >= 3.5) { color = "gold" - } else if (grade >= 0) { + } else if (colorgrade >= 0) { color = "crimson" } else { color = "gray" @@ -174,7 +175,7 @@ function addGrade(date,name,grade,link,fromPast) { for(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) + console.info("Powerology: Found same name with different grade:", name, ":", pastGrades.value[h][1][1], "=>", grade) pastGrades.value.splice(h,1) } else { match2 = true; @@ -189,38 +190,39 @@ function addGrade(date,name,grade,link,fromPast) { } } - container.innerHTML += ` - + container.insertAdjacentHTML("beforeend", ` +

${name}

${grade}

- ` + `) } function openGrades(type) { - let clsblacklist = [ - "General Information", - "Extended Essay", - "Creativity Activity Service" - ] - let includes = false - for(let i=0; i < classesarray.length; i++) { - includes = false - for(let h=0; h < clsblacklist.length; h++) { - if(classesarray[i][0].includes(clsblacklist[h])) { - includes = true + if(type == "mastery") { + let clsblacklist = [ + "General Information", + "Extended Essay", + "Creativity Activity Service", + "Post Oak Press", + ] + let includes = false + for(let i=0; i < classesarray.length; i++) { + includes = false + for(let h=0; h < clsblacklist.length; h++) { + if(classesarray[i][0].includes(clsblacklist[h])) { + includes = true + } } - } - if(!includes) { - if(type == "mastery") { - window.open(classesarray[i][1].replace("materials", "student_district_mastery")) - } else { - window.open(classesarray[i][1].replace("materials", "student_grades")) + if(!includes) { + window.open(classesarray[i][1].replace("materials", "student_district_mastery")) } - } + } else { + window.open("/grades/grades", "_self") } + } function filterGrades() { @@ -269,16 +271,21 @@ function setColor(id, name) { classColors.set() } -function toggleCngBg() { +function toggleCngBg(force = false) { widget = document.getElementById("bgbox") - if(widget.style.visibility == "hidden") { - widget.style.visibility = "" - document.getElementById("bgcolor").value = backGround.value[0] - document.getElementById("bgimg").value = backGround.value[1] - document.getElementById("bgblur").value = backGround.value[2] - } else { + if (force) { widget.style.visibility = "hidden" + } else { + if(widget.style.visibility == "hidden") { + widget.style.visibility = "" + document.getElementById("bgcolor").value = backGround.value[0] + document.getElementById("bgimg").value = backGround.value[1] + document.getElementById("bgblur").value = backGround.value[2] + } else { + widget.style.visibility = "hidden" + } } + } function saveBg() { @@ -292,6 +299,13 @@ function saveBg() { backGround.set() } +function closeBox(event) { + console.debug(event.clientX, event.clientY) + if(event.clientX >= 210 || event.clientY >= 500) { + toggleCngBg(true) + } +} + function editSavedGrades(argument="h", input=-1) { if(argument == "h") { console.info("a = add grade, r = remove grade, leave second argument blank for help") @@ -334,7 +348,7 @@ function unEscape(htmlStr) { return htmlStr; } -function onError(error) {console.debug("Error:", error)} +function onError(error) {console.debug("Powerology: Error:", error)} buttonfunctions = { "openGrades" : openGrades, @@ -347,4 +361,6 @@ buttonfunctions = { "saveBg" : saveBg, "filterGrades" : filterGrades, "openLink" : openLink, -} \ No newline at end of file +} + +document.addEventListener("click", closeBox); \ No newline at end of file diff --git a/extention/home/index.js b/extention/home/index.js index 5924478..1b08942 100644 --- a/extention/home/index.js +++ b/extention/home/index.js @@ -33,7 +33,7 @@ function loadSchoologyPlus() { gradesarray.push([[itime],[iname,igrade,ilink]]) } } catch (error) { - console.error("Error reading grades from Schoology page:\n", error) + console.error("Powerology: Error reading grades from Schoology page:\n", error) gradesarray.push([[-1],["Error - Check Console (f12) & Report to Aiden","-","/home"]]) } @@ -54,7 +54,7 @@ function loadSchoologyPlus() { classesarray.push([jname,jlink,jimage]) } } catch (error) { - console.error("Error reading classes from Schoology page:\n", error) + console.error("Powerology: Error reading classes from Schoology page:\n", error) classesarray.push(["Error - Check Console (f12) & Report to Aiden","/home",""]) } @@ -71,12 +71,12 @@ function loadSchoologyPlus() { hlink = assignments[h].getElementsByClassName("sExtlink-processed")[0].href assignmentsarray.push([hdate, hname, htime, hclass, hlink]) } catch(err) { - console.debug("Error in parsing assignments:", err) + console.debug("Powerology: Error in parsing assignments:", err) errorlist.push(`

Error reading assignment #: ${h}

`) } } } catch (error) { - console.error("Error reading assignments from Schoology page:\n", error) + console.error("Powerology: Error reading assignments from Schoology page:\n", error) assignmentsarray.push(["Error", "Error - Check Console (f12) & Report to Aiden", "-", "", "/home"]) } @@ -96,7 +96,7 @@ function loadSchoologyPlus() { } } } catch (error) { - console.error("Error reading overdue assignments from Schoology page:\n", error) + console.error("Powerology: Error reading overdue assignments from Schoology page:\n", error) overdueassignmentsarray.push(["Error - Check Console (f12) & Report to Aiden", "/home"]) } diff --git a/extention/home/variables.js b/extention/home/variables.js index b4daa8c..b00b4ad 100644 --- a/extention/home/variables.js +++ b/extention/home/variables.js @@ -41,13 +41,12 @@ schoologyplusplusWeb = ` function passFunctionCall(call) { document.getElementById('codeportal').innerHTML = call; } -console.debug("hey i work") Change Background