MyKCL Enhancement Suite

Enhancement Suite for the MyKCL website

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         MyKCL Enhancement Suite
// @namespace    http://com.marsharbour.modulehider
// @version      1.0
// @license MIT
// @description  Enhancement Suite for the MyKCL website
// @match        https://mykcl.kcl.ac.uk/urd/sits.urd/run/*
// @match        https://mykcl.kcl.ac.uk/urd/sits.urd/run/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Check if the current page has the title "Results Page"
    function isResultsPage() {
        return document.title.includes('View Module Results');
    }

    function addModuleHider() {
        // CSS Stylesheet
        const cssStyles = `
            table.gridtext.collapsed:not(.alignleft) tr:not(.modulerow) {
                display: none;
            }
        `;

        // Create the style element
        const styleElement = document.createElement('style');
        styleElement.innerHTML = cssStyles;
        document.head.appendChild(styleElement);
        styleElement.disabled = true;

        // Create the toggle button
        const toggleButton = document.createElement('button');
        toggleButton.textContent = 'Toggle Module Rows';

        // Find the <p> element with the ID "title"
        const titleElement = document.getElementById('title');

        if (titleElement) {
            // Append the toggle button to the after the title
            if (titleElement.nextElementSibling) {
                titleElement.parentNode.insertBefore(toggleButton, titleElement.nextElementSibling);
            } else {
                titleElement.parentNode.appendChild(toggleButton);
            }
        } else {
            // If the <p> element with the ID "title" is not found, append the toggle button to the body
            document.body.appendChild(toggleButton);
        }

        // Toggle the style element on button click
        toggleButton.addEventListener('click', function() {
            styleElement.disabled = !styleElement.disabled;
        });
    }

    // Add the style element and toggle button if on the results page
    function resultsPage() {
        addModuleHider()
    }

    function applyTweaks() {
        if (isResultsPage()) {
            resultsPage();
        }
    }

    applyTweaks()
})();