Nimo TV Better Theater Mode

Automatically toggle theater mode on Nimo TV

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Nimo TV Better Theater Mode
// @namespace    http://tampermonkey.net/
// @version      v0.1-alpha
// @description  Automatically toggle theater mode on Nimo TV
// @author       You
// @match        https://www.nimo.tv/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nimo.tv
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function hideSidebar() {
        const sidebar = document.querySelector(".nimo-room__main__sider");
        if (sidebar) {
            sidebar.style.display = "none";
            console.log("Sidebar hidden.");
        } else {
            console.log("Sidebar not found, retrying...");
        }
    }

     function betterTheaterMode() {
        const sidebar = document.querySelector(".nimo-room__theater-section");
        if (sidebar) {
            sidebar.style.width = "100%";
            console.log("Maximize Theater mode on");
        } else {
            console.log("Script failse, retry.....");
        }
    }

    function toggleTheaterMode() {
        const TheaterModeQueries = document.querySelector("div.theater-control");
        if (TheaterModeQueries) {
            const theaterButton = TheaterModeQueries.getElementsByClassName("nimo-icon nimo-icon-web-theater-off");
            if (theaterButton.length > 0) {
                theaterButton[0].click();
                hideSidebar();
                betterTheaterMode();
            } else {
                console.log("Already in Theater Mode");
            }
        } else {
            console.log("Theater mode control not found, retrying...");
        }
    }

    // Check for the theater mode button every second until it is found and clicked
    const checkInterval = setInterval(() => {
        toggleTheaterMode();
    }, 1000);

    // Stop checking once theater mode is toggled
    setTimeout(() => clearInterval(checkInterval), 10000); // Stop trying after 10 seconds
})();