Mess around with schoolbook.ge
当前为
// ==UserScript==
// @name Schoolbook Tools
// @namespace https://github.com/naviamold1
// @match https://eservices.schoolbook.ge/*
// @homepage https://greasyfork.org/en/scripts/459858-schoolbook-tools
// @grant GM_getValue
// @version 1.5
// @author Naviamold
// @description Mess around with schoolbook.ge
// @license MIT
// ==/UserScript==
(function () {
"use strict";
// do not change anything here if you dont know what you are doing!
function newGrade(grade) {
let grades = document.querySelectorAll(".avg_value");
let totalGrade = document.querySelectorAll("#saertosashualo span");
const final = [...grades, ...totalGrade];
final.forEach((val) => (val.innerHTML = grade));
}
function newAttendance(attendance) {
let attendances = document.querySelectorAll(".prc");
let totalAttendance = document.querySelectorAll(".sec span");
const final = [...attendances, ...totalAttendance];
final.forEach((val) => (val.innerHTML = attendance));
}
function removeComments() {
let comment = document.querySelectorAll(".notificationsList");
let comment1 = document.querySelectorAll(".notificationsListalter");
let messages = document.querySelectorAll(".homeworkContent");
const final = [...comment, ...comment1, ...messages];
final.forEach((mes) => (mes.style.display = "none"));
}
function liveUpdate() {
let totalGrade = document.querySelector("#saertosashualo span");
totalGrade.click();
setTimeout(() => {
closeGradeDialog();
let numbers = [];
document
.querySelectorAll(
"#cnt > div.div_container_grades > table > tbody > tr > td:nth-child(4)"
)
.forEach((el) => {
let text = el.innerText || el.textContent;
let number = parseInt(text.replace(/\D/g, ""));
if (!isNaN(number)) {
numbers.push(number);
}
});
let sum = numbers.reduce((acc, val) => acc + val, 0);
let avg = 0;
if (numbers.length > 0) {
avg = sum / numbers.length;
}
avg = Math.round(avg * 100) / 100;
totalGrade.innerHTML = avg;
}, 1000);
}
function gradeSpier() {
$("body").append(`
<form id="gmSomeID">
<input placeholder="Grade Viewer - ID" id="gminput">
<button id="gmview">View</button>
</form>
`);
const getter = (e) => {
e.preventDefault();
let val = document.querySelector("#gminput").value;
gradeclick(val, -1);
};
$("#gmview").click(getter);
}
function attendanceSpier() {
$("body").append(`
<form id="gmSomeID2">
<input placeholder="Attendance Viewer - ID" id="gminput2">
<input placeholder="Subject ID" id="gminput3">
<button id="gmview2">View</button>
</form>
`);
const getter = (e) => {
e.preventDefault();
let val = document.querySelector("#gminput2").value;
let val2 = document.querySelector("#gminput3").value;
attendanceclick(val, val2);
};
$("#gmview2").click(getter);
}
if (
window.location.href === "https://eservices.schoolbook.ge/Parent/Index" ||
window.location.href ===
"https://eservices.schoolbook.ge/Parent/AllSubjects"
) {
if (GM_getValue("changeGrade")) {
setTimeout(() => {
newGrade(GM_getValue("changeGrade"));
}, 100);
}
if (GM_getValue("changeAttendance")) {
setTimeout(() => {
newAttendance(GM_getValue("changeAttendance"));
}, 100);
}
if (GM_getValue("liveGradeUpdate")) {
liveUpdate();
}
if (GM_getValue("gradeViewer")) {
gradeSpier();
}
if (GM_getValue("attendanceViewer")) {
attendanceSpier();
}
}
if (
window.location.href === "https://eservices.schoolbook.ge/Parent/Messages"
) {
if (GM_getValue("hideComments")) {
removeComments();
}
}
})();