kgc

grade change script

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         kgc
// @namespace    http://tampermonkey.net/
// @license MIT
// @version      1.0
// @description  grade change script
// @author       Minoa
// @match        https://login-learn.k12.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to get letter grade based on percentage
    function getLetterGrade(percent) {
        if (percent >= 90) return 'A';
        if (percent >= 80) return 'B';
        if (percent >= 70) return 'C';
        if (percent >= 60) return 'D';
        return 'F';
    }

    // Function to modify grade percentage and letter
    function modifyGrade(gradeElement) {
        const percentElement = gradeElement.querySelector('.grade-percent');
        const letterElement = gradeElement.querySelector('.grade-letter');
        if (!percentElement) return;

        // extract current percentage (remove % symbol if present)
        const currentPercent = parseFloat(percentElement.textContent.replace('%', ''));
        if (isNaN(currentPercent)) return;

        let newPercent = currentPercent;

        // handle grades above 90%
        if (currentPercent > 90) {
            const firstDigit = Math.floor(currentPercent / 10);
            const secondDigit = currentPercent % 10;
            newPercent = currentPercent - (firstDigit + secondDigit / 10);
        }
        // handle grades below 72%
        else if (currentPercent < 72) {
            newPercent = currentPercent + 3;
        }

        // ensure grade never exceeds 100%
        newPercent = Math.min(100, newPercent).toFixed(1);
        percentElement.textContent = newPercent + '%';

        // update letter grade if element exists
        if (letterElement) {
            letterElement.textContent = getLetterGrade(parseFloat(newPercent));
        }
    }

    // Function to process all grade elements
    function processGrades() {
        const gradeElements = document.querySelectorAll('div.grade');
        gradeElements.forEach(modifyGrade);
    }

    // Create MutationObserver to handle dynamically loaded content
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                processGrades();
            }
        });
    });

    // Initial processing
    processGrades();

    // Start observing document for dynamic changes
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();