VTC Moodle: Auto-hide Sidebar

Hide the sidebar automatically after the page loaded.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

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