Attendance Boost (Optimized)

Faster, event-based attendance boost

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

(I already have a user style manager, let me install it!)

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

})();