Greasy Fork is available in English.

Calculate Missed Hours for Classes

Automatically calculates the total hours missed for each class based on attendance records.

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 or Violentmonkey 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.

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

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         Calculate Missed Hours for Classes
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically calculates the total hours missed for each class based on attendance records.
// @match        https://stars.bilkent.edu.tr/srs/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function calculateMissedHours() {
        const attendanceDivs = document.querySelectorAll(".attendDiv");
        const results = [];

        attendanceDivs.forEach(attendDiv => {
            const className = attendDiv.querySelector("h4")?.innerText.trim() || "Unknown Class";
            const attendanceRows = attendDiv.querySelectorAll("table tr");
            let totalMissedHours = 0;

            attendanceRows.forEach((row, index) => {
                if (index === 0) return;
                const attendanceCell = row.cells[2];
                if (attendanceCell) {
                    const attended = parseInt(attendanceCell.querySelector("b")?.innerText || "0");
                    const total = parseInt(attendanceCell.innerText.split("/")[1].trim());
                    const missed = total - attended;
                    totalMissedHours += missed;
                }
            });

            results.push({ className, totalMissedHours });
        });

        if (results.length > 0) {
            results.forEach(result => {
                console.log(`Class: ${result.className}, Total Hours Missed: ${result.totalMissedHours}`);
                alert(`Class: ${result.className}, Total Hours Missed: ${result.totalMissedHours}`);
            });
        } else {
            console.log("No attendance data found.");
            alert("No attendance data found.");
        }
    }

    // Run the function automatically
    calculateMissedHours();
})();