Keio Timetable Simplifier

Fix the disgusting UI

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Keio Timetable Simplifier
// @namespace    http://keio.jp/
// @version      2026-04-07
// @description  Fix the disgusting UI
// @author       Chippppp
// @match        https://gacad.keio.jp/rishu/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=keio.jp
// @grant        none
// @license      MIT
// ==/UserScript==

(() => {
    "use strict";

    const style = document.createElement("style");
    style.innerHTML = `
        .tm-toggle-container {
            position: fixed; bottom: 20px; right: 20px; z-index: 9999;
            background: #fff; padding: 10px; border: 1px solid #ccc; border-radius: 8px;
            display: flex; align-items: center; gap: 8px; font-family: sans-serif; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .switch {
            position: relative; display: inline-block; width: 40px; height: 22px;
        }
        .switch input { opacity: 0; width: 0; height: 0; }
        .slider {
            position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
            background-color: #ccc; transition: .4s; border-radius: 34px;
        }
        .slider:before {
            position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
            background-color: white; transition: .4s; border-radius: 50%;
        }
        input:checked + .slider { background-color: #2196F3; }
        input:checked + .slider:before { transform: translateX(18px); }

        body.keio-timetable-simplifier-hidden-mode tbody :is(.credit, .sms, .estb, .regno, .fld, .knumlmode, .btn) {
            display: none !important;
        }
    `;
    document.head.appendChild(style);

    const container = document.createElement("div");
    container.className = "tm-toggle-container";
    container.innerHTML = `
        <span style="font-size:12px; color:#333;">シンプルモード</span>
        <label class="switch">
            <input type="checkbox" id="tm-badge-toggle" checked>
            <span class="slider"></span>
        </label>
    `;
    document.body.appendChild(container);

    document.body.classList.add("keio-timetable-simplifier-hidden-mode");

    const checkbox = document.getElementById("tm-badge-toggle");

    checkbox.addEventListener("change", function() {
        if (this.checked) {
            document.body.classList.add("keio-timetable-simplifier-hidden-mode");
        } else {
            document.body.classList.remove("keio-timetable-simplifier-hidden-mode");
        }
    });

    document.addEventListener("click", (event) => {
        if (!document.body.classList.contains("keio-timetable-simplifier-hidden-mode")) return;
        if (event.target.tagName === "BUTTON") return;
        const innerItem = event.target.closest(".inner-item");

        if (innerItem) {
            let element = event.target;
            for (; ; ) {
                if (element.getAttribute("name") !== null && element.getAttribute("name").includes("cell-")) {
                    if (element.children[element.children.length - 1].tagName === "SPAN") element.children[element.children.length - 1].children[0].click();
                    else element.nextElementSibling.children[1].children[0].click();
                    break;
                }
                element = element.parentElement;
                if (element === innerItem) break;
            }
        } else if (event.target.classList.contains("cell") && event.target.childElementCount === 1 && event.target.children[0].tagName === "BUTTON") {
            event.target.children[0].click();
        }
    });
})();