Attendance Boost (Optimized)

Faster, event-based attendance boost

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Attendance Boost (Optimized)
// @namespace    http://tampermonkey.net/
// @version      9.0
// @description  Faster, event-based attendance boost
// @match        https://arsdcollege.in/Internet/Student/Attendance_Report_Monthly.aspx
// @run-at       document-end
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  const BOOST = 12;

  const getText = (el) =>
    (el.textContent || '').replace(/\s+/g, ' ').trim();

  function applyFix() {
    const dEl = document.getElementById('lbl_Tot_LD');
    const aEl = document.getElementById('lbl_Tot_LA');
    const pEl = document.getElementById('lbl_percentage');

    if (!dEl || !aEl || !pEl) return;

    const delivered = parseInt(getText(dEl));
    const attended = parseInt(getText(aEl));

    if (!delivered || isNaN(attended)) return;

    const newAttended = Math.min(attended + BOOST, delivered);
    const newPct = ((newAttended / delivered) * 100).toFixed(2);

    // Only update if needed (prevents unnecessary DOM writes)
    if (aEl.textContent != newAttended) {
      aEl.textContent = newAttended;
      pEl.textContent = `Percent Attd. (Including Medical): ${newPct}`;

      console.log(
        `[AttFixer] ✅ ${attended} + ${BOOST} = ${newAttended} | ${newPct}%`
      );
    }
  }

  // Run immediately
  applyFix();

  // 🔥 Observe DOM changes instead of polling
  const observer = new MutationObserver(() => applyFix());

  observer.observe(document.body, {
    childList: true,
    subtree: true,
  });

})();