Greasy Fork

Greasy Fork is available in English.

chzzk-1080p

치지직 1080p 해상도로 고정합니다

当前为 2024-11-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         chzzk-1080p
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  치지직 1080p 해상도로 고정합니다
// @match        *://chzzk.naver.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function setResolution() {
        const qualityItems = document.querySelectorAll(
            '.pzp-pc-setting-quality-pane__list-container li'
        );

        if (!qualityItems) {
            console.error("해상도 설정 요소를 찾을 수 없습니다.");
            return;
        }

        // 1080p 항목 찾기 (없을 수도 있음)
                let targetQuality = qualityItems.item(0);

                //1080p 또는 720p 항목 찾기
        for (let i = 0; i < qualityItems.length; i++) {
            const item = qualityItems[i];
            if (item.textContent.includes("1080p")) {
                targetQuality = item;
                break;
            } else if (item.textContent.includes("720p")) {
                                targetQuality = item;
                        }
        }
                
                if (targetQuality) {
                        targetQuality.click();
                        console.log("해상도가 설정되었습니다. (" + targetQuality.textContent + ")");
                } else {
                        console.error("1080p 또는 720p 해상도를 찾을 수 없습니다.");
                }
    }

    function fixScrollIssue() {
        // overflow 속성 조정
                try {
                document.body.style.overflow = 'auto';
        document.documentElement.style.overflow = 'auto';
                } catch(e){
                        console.error("overflow 속성 조정 실패:", e);
                }
                
                try {
                // position 속성 조정
        document.body.style.position = 'relative';
        document.documentElement.style.position = 'relative';
                } catch(e) {
                        console.error("position 속성 조정 실패:", e);
                }
                
                try {
                // height 속성 조정
        document.body.style.height = 'auto';
        document.documentElement.style.height = 'auto';
                } catch(e) {
                        console.error("height 속성 조정 실패:", e);
                }
        console.log("스크롤 문제가 수정되었습니다.");
    }

    function applySettingsOnSpecificPages() {
        if (
            location.href.startsWith("https://chzzk.naver.com/live/") ||
            location.href.startsWith("https://chzzk.naver.com/video")
        ) {
                        // 1초 간격으로 반복. 페이지 로딩 속도에 따라 조정 필요
                        setTimeout(() => {
                                setResolution();
                        }, 1000);
            fixScrollIssue();
        } else {
            fixScrollIssue();
        }
    }

    // 페이지 로드 시 설정 적용
    window.addEventListener("load", applySettingsOnSpecificPages);

    // URL 변경 감지하여 설정 재적용 - 더 안정적인 방법
    let lastUrl = location.href;
    const urlCheckInterval = setInterval(() => {
        if (location.href !== lastUrl) {
            lastUrl = location.href;
            applySettingsOnSpecificPages();
        }
    }, 2000); // 2초 간격으로 확인. 너무 짧으면 성능 저하 가능.
})();