Greasy Fork

치지직 팔로우 목록 자동 새로고침 + 자동 펼치기

팔로우 목록을 원하는 시간마다 반복 새로고침 + 팔로우 목록을 자동으로 전부 펼칩니다.

当前为 2025-07-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         치지직 팔로우 목록 자동 새로고침 + 자동 펼치기
// @namespace    http://tampermonkey.net/
// @version      20250704
// @description  팔로우 목록을 원하는 시간마다 반복 새로고침 + 팔로우 목록을 자동으로 전부 펼칩니다.
// @match        *://chzzk.naver.com/*
// @icon         https://chzzk.naver.com/favicon.ico
// @grant        none
// @author       Lusyeon | 루션
// @license      MIT
// ==/UserScript==

// Name: Chzzk Auto Follow Refresher
// Description: Automatically refreshes the Chzzk sidebar follow list and expands all followed channels.
(function () {
    'use strict';

const refreshInterval = 60000; // 1분마다 팔로우 목록 자동 새로고침 - Refresh follow list every 1 minute
const hideOffline = 0; // 오프라인 스트리머 숨기기 여부 설정 (1이면 숨김, 0이면 숨기지 않음) - Whether to hide offline streamers: 1 to hide, 0 to show

    function clearCountDisplay() {
        const old = document.querySelector('.live_offline_count');
        if (old) old.remove();
    }

function updateCounts() {
    const listContainer = document.querySelector('.navigator_list__cHnuV');
    if (!listContainer) return;

    const items = listContainer.querySelectorAll('a.navigator_item__qXlq9');

    let live = 0;
    let total = 0;

    items.forEach(item => {
        const blind = item.querySelector('div.navigator_profile__kAP2J span.blind')?.textContent.trim();


        if (blind === 'LIVE' || blind === '오프라인') {
            total++;


            if (blind === 'LIVE' && item.style.display !== 'none') {
                live++;
            }
        }
    });

    const header = document.querySelector('.navigator_header__inwmE h2.navigator_title__9RhVJ');
    if (!header) return;


    const old = header.querySelector('.live_offline_count');
    if (old) old.remove();

    const span = document.createElement('span');
    span.className = 'live_offline_count';
    span.style.fontSize = '0.9em';
    span.style.fontWeight = 'normal';
    span.style.color = '#888';
    span.style.marginLeft = '8px';
    span.textContent = `${live} / ${total}`;
    header.appendChild(span);
}

    function clickMoreButtonsSequentially(callback) {
        const btn = document.querySelector('button.navigator_button_more__UE0v3[aria-expanded="false"]');
        if (btn) {
            btn.click();
            setTimeout(() => clickMoreButtonsSequentially(callback), 700);
        } else {
            if (callback) callback();
        }
    }

    function hideOfflineItemsIfNeeded() {
        if (hideOffline !== 1) return;
        const items = document.querySelectorAll('a.navigator_item__qXlq9');
        items.forEach(item => {
            const profile = item.querySelector('div.navigator_profile__kAP2J');
            const blind = profile?.querySelector('span.blind')?.textContent.trim();
            item.style.display = (blind === '오프라인') ? 'none' : '';
        });
    }

    function clickRefreshButton() {
        const btns = document.querySelectorAll('button.navigator_button__BbAEb');
        for (const btn of btns) {
            const span = btn.querySelector('span.blind');
            if (span?.textContent.trim() === '새로고침') {
                btn.click();
                return true;
            }
        }
        return false;
    }

    function refreshAndProcess() {
        if (!clickRefreshButton()) return;

        setTimeout(() => {
            clickMoreButtonsSequentially(() => {
                hideOfflineItemsIfNeeded();
                updateCounts();
            });
        }, 2000);
    }

    function triggerInitialRun() {
        if (window.__chzzk_follow_initialized__) return;
        window.__chzzk_follow_initialized__ = true;
        setTimeout(refreshAndProcess, 1000);
    }


    window.addEventListener('DOMContentLoaded', triggerInitialRun);
    window.addEventListener('load', triggerInitialRun);
    setTimeout(triggerInitialRun, 3000);


    setInterval(refreshAndProcess, refreshInterval);


    document.addEventListener('click', e => {
        const btn = e.target.closest('button.navigator_button__BbAEb');
        const text = btn?.querySelector('span.blind')?.textContent.trim();
        if (text === '새로고침') {
            setTimeout(() => {
                clickMoreButtonsSequentially(() => {
                    hideOfflineItemsIfNeeded();
                    updateCounts();
                });
            }, 1500);
        }
    });


    const observer = new MutationObserver(() => {
        if (hideOffline === 1) {
            hideOfflineItemsIfNeeded();
        }


        const countExists = !!document.querySelector('.live_offline_count');
        const header = document.querySelector('.navigator_header__inwmE h2.navigator_title__9RhVJ');
        if (header && !countExists) {
            updateCounts();
        }
    });

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

})();