VTC Moodle:自動隱藏側邊欄

在頁面載入後自動隱藏側邊欄。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name               VTC Moodle: Auto-hide Sidebar
// @name:zh-TW         VTC Moodle:自動隱藏側邊欄
// @description        Hide the sidebar automatically after the page loaded.
// @description:zh-TW  在頁面載入後自動隱藏側邊欄。
// @icon               https://icons.duckduckgo.com/ip3/moodle2526.vtc.edu.hk.ico
// @author             Jason Kwok
// @namespace          https://jasonhk.dev/
// @version            1.0.0
// @license            MIT
// @match              https://moodle2526.vtc.edu.hk/*
// @run-at             document-end
// @grant              none
// @supportURL         https://greasyfork.org/scripts/551368/feedback
// ==/UserScript==

const body = document.body;
const toggle = document.querySelector(".tgsdbb_toggle");
if (toggle)
{
    const interval = setInterval(() =>
    {
        if (!body.classList.contains("tgsdbb_open"))
        {
            clearInterval(interval);
            return;
        }

        toggle.click();
    }, 50);
}