schoolbook.ge tools

Mess around with schoolbook.ge

目前為 2023-02-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        schoolbook.ge tools
// @namespace   https://github.com/Naviamold1
// @match       https://eservices.schoolbook.ge/*
// @grant       none
// @version     1.1
// @author      Naviamold
// @description Mess around with schoolbook.ge
// @license MIT
// ==/UserScript==

(function () {
  "use strict";

  // fill out these fields
  let changeGrade = "None"; // numbers or "None"
  let hideComments = false; // true or false
  let changeAttandance = "None"; // numbers or "None"
  let liveGradeUpdate = true; // true or false
  let gradeViewer = false; // true of false

  // do not change anything below this line if you dont know what you are doing

  function newGrade() {
    let grade = document.getElementsByClassName("avg_value");
    for (let i = 0; i < grade.length; i++) {
      grade[i].innerHTML = changeGrade;
    }
    let totalGrade = document.querySelector("#saertosashualo span");
    totalGrade.innerHTML = changeGrade;
    for (let i = 0; i < totalGrade.length; i++) {
      totalGrade[i].innerHTML = changeGrade;
    }
  }

  function newAttandance() {
    let attendance = document.querySelector(".sec span");
    attendance.innerHTML = changeAttandance + " %";
  }

  function removeComments() {
    let comment = document.getElementsByClassName("notificationsList");
    for (let i = 0; i < comment.length; i++) {
      comment[i].style.display = "none";
    }
    let comment1 = document.getElementsByClassName("notificationsListalter");
    for (let i = 0; i < comment1.length; i++) {
      comment1[i].style.display = "none";
    }
    let messages = document.getElementsByClassName("homeworkContent");
    for (let i = 0; i < messages.length; i++) {
      messages[i].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;
    }, 500);
  }

  function gradeSpier() {
    $("body").append(`
    <form id="gmSomeID">
    <input id="gminput"></input>
    <button id="gmview">View</button>
    </form>
    `);
    const getter = () => {
      let val = document.querySelector("#gminput").value
      gradeclick(val, -1);
    };
    $("#gmview").click(getter);
  }

  if (window.location.href == "https://eservices.schoolbook.ge/Parent/Index") {
    if (changeGrade != "None") {
      newGrade();
    }
    if (changeAttandance != "None") {
      newAttandance();
    }
  }

  if (
    window.location.href == "https://eservices.schoolbook.ge/Parent/Messages"
  ) {
    if (hideComments) {
      removeComments();
    }
  }

  if (liveGradeUpdate) {
    liveUpdate();
  }

  if (gradeViewer) {
    gradeSpier();
  }
})();