ch_th

극장모드

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         ch_th
// @namespace    ch_th
// @version      0.0.1
// @description  극장모드
// @author       lc2122
// @match        https://chzzk.naver.com/*
// @match        https://lolcast.web.app/*
// @match        https://lolcast.kr/*

// ==/UserScript==

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

    let url = document.location.href;

    // 최상위 창(일반 치지직 시청)일 경우 스크립트 종료, 임베드(iframe) 환경에서만 실행
    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;
                }
            }
        }

        // 채팅창 닫기 버튼 클릭
        let chatCloseButton = document.querySelector('[class^="live_chatting_header_button__"]');
        if (chatCloseButton) {
            chatCloseButton.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();
            });
        }
        player.muted = true; // 비디오 음소거
    });

})();