Nimo TV Better Theater Mode

Automatically toggle theater mode on Nimo TV

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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
})();