Attendance Boost (Optimized)

Faster, event-based attendance boost

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

})();