Attendance Boost (Optimized)

Faster, event-based attendance boost

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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

})();