Schoolbook Tools

Mess around with schoolbook.ge

当前为 2023-05-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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();
    }
  }
})();