MyKCL Enhancement Suite

Enhancement Suite for the MyKCL website

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey 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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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