Greasy Fork

Greasy Fork is available in English.

chzzk theater mode

채팅창 가리기 + 넓은 화면

当前为 2025-02-18 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         chzzk theater mode
// @namespace    chzzk theater mode
// @version      0.1
// @description  채팅창 가리기 + 넓은 화면
// @author       lc2122
// @match        https://chzzk.naver.com/*
// ==/UserScript==

(function () {
    'use strict';
    let debug = false;

    let url = document.location.href;

    if (url.indexOf("//chzzk.naver.com/") !== -1) {
        let isTopWindow = window.self === window.top;
        if (isTopWindow) {
            return;
        }

        if (debug) console.log("chzzk embed", url);

        function waitForElement(selector, callback) {
            const existingElement = document.querySelector(selector);

            if (existingElement) {
                callback(existingElement);
            } else {
                const observer = new MutationObserver((mutationsList) => {
                    const targetElement = document.querySelector(selector);
                    if (targetElement) {
                        observer.disconnect();
                        callback(targetElement);
                    }
                });

                observer.observe(document.documentElement, {
                    childList: true,
                    subtree: true,
                });
            }
        }

        let player = undefined;
        let handleVideoReadyFired = false;

        let handleVideoReady = function(){
            if (handleVideoReadyFired) return;
            handleVideoReadyFired = true;
            let viewmode_buttons = document.querySelectorAll(".pzp-pc__viewmode-button");
            if(viewmode_buttons.length == 1){
                viewmode_buttons[0].click();
            }
            else{
                for (let i = 0; i < viewmode_buttons.length; i++) {
                    let button = viewmode_buttons[i];
                    if (button.getAttribute('aria-label') === '넓은 화면') {
                        button.click();
                        break;
                    }
                }
            }
            document.querySelector('[class^="live_chatting_header_button__"]').click();
        };

        waitForElement("video.webplayer-internal-video", function (node) {
            if (debug) console.log("found video player", node);
            player = node;
            if (player.readyState >= 2) {
                handleVideoReady();
            } else {
                player.addEventListener('loadedmetadata', function once() {
                    player.removeEventListener('loadedmetadata', once);
                    handleVideoReady();
                });
            }
        });

    }

})();