Keio Timetable Simplifier

Fix the disgusting UI

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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