kone
소미소프트

소미소프트

댓글 자동확장 개선 스크립트

05/31/2025, 08:06:09
유틸
2238 views · 6 likes

https://kone.gg/s/somisoft/b3Kid-M_YjOKD_kofh5zyb

여기 이분 스크립트에서 챗지피티로 댓글 확장 코드만 추출 후 개선한 스크립트입니다. 문제시 글삭함

원본 작성자가 삭제 요청시 글내림(허락받음ㅎ). 오류 생기면 스크립트 삭제 추천


1

원본 댓글 확장은 대댓 확장만 자동이고 댓글 더 불러오기는 자동이 아니라서 추가했습니다.


1
1

템퍼몽키 확장프로그램 받으시고 새 스크립트 만들기 > 안에 내용 지우고 스크립트 복붙 > 파일 저장


아래는 스크립트입니다.

// ==UserScript==
// @name         kone 댓글 자동 확장 + 더 불러오기
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  kone.gg에서 댓글을 자동으로 확장하고 '댓글 더 불러오기'도 자동 클릭합니다.
// @author       김머시기
// @match        https://kone.gg/*
// @grant        none
// @license      MIT
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';

    function clickAllExpandButtons() {
        const expandButtons = document.querySelectorAll('button');
        let clickedAny = false;

        expandButtons.forEach(button => {
            try {
                const text = button.textContent.trim();
                const isCommentExpand = /^\d+개의 댓글$/.test(text);
                const isLoadMore = text === '댓글 더 불러오기';

                if ((isCommentExpand || isLoadMore) && button.offsetParent !== null) {
                    button.click();
                    clickedAny = true;
                }
            } catch (e) {
                // 무시
            }
        });

        if (clickedAny) {
            // 여전히 확장할 수 있는 버튼이 남아있을 수 있으므로 재귀 호출
            setTimeout(clickAllExpandButtons, 500);
        }
    }

    function updateGlobalStyles() {
        const styleFix = document.createElement('style');
        styleFix.textContent = `
            .comment-wrapper,
            .comment-wrapper .overflow-x-auto,
            .comment-wrapper .overflow-hidden,
            .thread-body-content .overflow-hidden {
                overflow: visible !important;
                max-height: none !important;
            }
        `;
        document.head.appendChild(styleFix);
    }

    function runCommentFix() {
        clickAllExpandButtons();
        updateGlobalStyles();
    }

    const observer = new MutationObserver(() => {
        clearTimeout(commentFixTimer);
        commentFixTimer = setTimeout(runCommentFix, 100);
    });

    let commentFixTimer = null;

    observer.observe(document.body, { childList: true, subtree: true });
    observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });

    function observeURLChange() {
        let lastUrl = location.href;

        const urlChangeHandler = () => {
            if (location.href !== lastUrl && location.href.includes('/s/')) {
                lastUrl = location.href;
                setTimeout(runCommentFix, 500);
            }
        };

        const urlObserver = new MutationObserver(urlChangeHandler);
        urlObserver.observe(document.body, { childList: true, subtree: true });

        const originalPush = history.pushState;
        history.pushState = function () {
            originalPush.apply(this, arguments);
            urlChangeHandler();
        };

        window.addEventListener('popstate', urlChangeHandler);
    }

    const init = () => {
        runCommentFix();
        observeURLChange();
    };

    if (document.readyState === 'complete' || document.readyState === 'interactive') {
        init();
    } else {
        document.addEventListener('DOMContentLoaded', init);
    }
})();
6
1 comment
07/30/25
개추콘
의술사 질문있어용
질문
nghj7722
05/18 5404 0
셀레스포니아 간단후기
후기 및 공략
띠띠용
05/18 5793 6
[복구요청] 인형사의 꿈과 각성 RJ402479
요청
manru
05/18 3931 2
[복구요청] 세라&노엘 ~사로잡힌 프린세스의 행방~
요청
manru
05/18 5565 0
『이세계 NTR 여관 ~연인과 여동생이 모르는 사이에 빼앗겨 가는~ [이세야도]』심사제출 및 소식
정보
wouwouer
05/18 13915 42
사라져서 슬픈 VAM작가 전체 공유
영상
hannanas
05/18 24236 67
비월선행록 패트론패치 받을 때 이거 어떻게 해결하나요?
질문
폴폴구리
05/18 8422 2
게임 추천받을 겸 쓰는 게임 후기(스포)
후기 및 공략
lastnightonearth
05/18 13671 32
라이딩 듀얼 엑셀러레이션!
일반
에로탐구가
05/18 2225 4
친구가 아다 땟다길래 보지가 만지면 무슨느낌이냐고 물어봣는데
일반
aktmxj3333
05/18 3702 0
비월 질문
질문
sorbe123
05/18 3036 0
시퀄 시리즈 콜로니 질문
질문
zetabobim
05/18 3117 1
[복구요청][RJ01030409]오호오호안 배덕 음성 집대성
요청
pukimon
05/18 3989 0
시퀄 시리즈는 무조건 순서대로 해야함?
질문
pataya
05/18 6448 1
던브 다좋은데 좀 아쉬운거
일반
nagisa8262
05/18 3363 1
던브에서 측실 만들 수 있나
일반
nagisa8262
05/18 3696 1
ai, 원신) 해등절에 감우에게 고백하고 잔뜩 사랑을 나누었다
야짤
kjh9304
05/18 8039 97
thron sin 갤러리
질문
kun3243
05/18 2654 0
도내S급문무양도재색겸비상냥치유계데레소꿉친구한테 키워지고싶다
일반
인생좆망함
05/18 8201 0
던브) 폴라리스 스텟 은근 화나네
일반
nagisa8262
05/18 5054 0
[kiliu] 데스퍽유
동인
agnet666
05/18 24708 81
[합동지] (블아) 두근두근 심야의 티파티
동인
agnet666
05/18 16924 45
영어코믹번역사이트 추천부탁드려요
질문
lkh0361
05/18 4679 -3
만화 두개 찾는데 혹시 제목 아는사람 좀 알려주라
질문
ldzofg342
05/18 3689 2
타코린 야짤이 개꼴림 ㄹㅇ..
일반
ㅇㅇ
05/18 3906 4
[복구요청]goons raid her
요청
애기밥통
05/18 4243 0
뇌가 뜌땨이 되었나봐
일반
minspie
05/18 4230 0
던브 스포) 블루 개꼬시다 ㅋㅋㅋㅋ
일반
nagisa8262
05/18 3310 0
의술사 몇가지 질문모음(스포 있을지도)
질문
rlawjddms
05/18 3873 -1
의술사 마스터피스 2페 기믹이 있음?
질문
simya1557
05/18 5557 0