kone
소미소프트

소미소프트

댓글 최신순/등록순 버튼 분리(댓글 새로고침) 스크립트

05/31/2025, 07:46:47
유틸
1683 views · 2 likes

챗지피티로 만든 스크립트입니다 문제시 글삭함

오류생기면 삭제 추천


최신순/등록순 버튼을 분리하는 이유

-버튼을 누르면 댓글이 새로고침 되면서 최신순/등록순으로 바뀌는데 나는 새로고침만 하고싶기 때문!

(사실 버튼 연속으로 두번 누르면 되니깐 없어도 되는 스크립트..)


그래서 작동 원리도

최신순 > 최신순 버튼 클릭: 등록순으로 일시 전환 > 다시 최신순으로 복귀함

최신순 > 등록순 버튼 클릭: 그냥 등록순으로 전환됨

등록순 > 등록순 버튼 클릭: 최신순으로 일시 전환 > 다시 등록순으로 복귀함

등록순 > 최신순 버튼 클릭: 그냥 최신순으로 전환됨


이런 원리임..

1

ㄴ원래 최신순/등록순 버튼


1

ㄴ스크립트로 분리된 최신순 버튼과 등록순 버튼





1
1

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


아래는 스크립트 입니다.

// ==UserScript==
// @name         kone.gg 댓글 정렬 버튼 분리
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  kone.gg의 원래 정렬 버튼 UI로 최신순/등록순 버튼을 분리해서 추가
// @match        https://kone.gg/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function getOriginalSortButton() {
        const buttons = document.querySelectorAll('button[data-slot="button"]');
        return Array.from(buttons).find(btn =>
            btn.textContent.includes('최신순') || btn.textContent.includes('등록순')
        );
    }

    function clickToForceSort(targetSort) {
        const sortBtn = getOriginalSortButton();
        if (!sortBtn) return;

        const isAlreadyTarget = sortBtn.textContent.includes(targetSort);
        const oppositeSort = targetSort === '최신순' ? '등록순' : '최신순';

        if (isAlreadyTarget) {
            sortBtn.click();
            setTimeout(() => {
                const newSortBtn = getOriginalSortButton();
                if (newSortBtn) newSortBtn.click();
            }, 150);
        } else {
            sortBtn.click();
        }
    }

    function createSortBtn(id, label, iconPathD, targetSort) {
        const btn = document.createElement('button');
        btn.id = id;
        btn.setAttribute('data-slot', 'button');
        btn.className = `
            border-0 justify-center whitespace-nowrap text-sm font-medium transition-all
            disabled:pointer-events-none disabled:opacity-50
            [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4
            shrink-0 [&_svg]:shrink-0 outline-none
            aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40
            aria-invalid:border-destructive hover:bg-accent dark:hover:bg-accent/50
            h-8 px-3 rounded-full -[>svg]:px-2.5 flex items-center gap-1.5
            text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-200 cursor-pointer
        `.trim();

        const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
        svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
        svg.setAttribute('width', '24');
        svg.setAttribute('height', '24');
        svg.setAttribute('viewBox', '0 0 24 24');
        svg.setAttribute('fill', 'none');
        svg.setAttribute('stroke', 'currentColor');
        svg.setAttribute('stroke-width', '2');
        svg.setAttribute('stroke-linecap', 'round');
        svg.setAttribute('stroke-linejoin', 'round');
        svg.classList.add('lucide', 'size-4');
        const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
        path.setAttribute('d', iconPathD);
        svg.appendChild(path);

        btn.appendChild(svg);
        btn.appendChild(document.createTextNode(` ${label}`));
        btn.style.marginLeft = '8px';

        btn.addEventListener('click', () => {
            clickToForceSort(targetSort);
        });

        return btn;
    }

    function addSortButtons() {
        const commentHeader = document.querySelector('.p-4.md\\:px-6.flex.justify-between.items-center');
        if (!commentHeader) return;

        const leftSection = commentHeader.querySelector('.flex.gap-4.items-center');
        if (!leftSection) return;

        if (document.querySelector('#sort-newest-btn')) return;

        // 최신순 (화살표 아래로)
        const newestPath = "m3 16 4 4 4-4 M7 20V4 M11 4h10 M11 8h7 M11 12h4";
        const newestBtn = createSortBtn('sort-newest-btn', '최신순', newestPath, '최신순');

        // 등록순 (화살표 위로)
        const oldestPath = "m3 8 4-4 4 4 M7 4v16 M11 12h4 M11 16h7 M11 20h10";
        const oldestBtn = createSortBtn('sort-oldest-btn', '등록순', oldestPath, '등록순');

        leftSection.appendChild(newestBtn);
        leftSection.appendChild(oldestBtn);

        const original = getOriginalSortButton();
        if (original) original.style.display = 'none';
    }

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

    addSortButtons();
})();
2
4 comments
유틸은 언제나 개추야
진짜 쓸데없는 스크립튼데 ㄳㄳ..
05/31/25
어.. 그럼 기존 order 버튼은 그냥 냅두고 새로고침 버튼만 추가하면 대는거 아닌가
05/31/25 Edited 05/31/25
이것저것 만져봤는데 제 능력부족으로 댓글창만 새로고침만 하는건 안되더라구요 ㅠㅠ 최신순/등록순 버튼으로 댓글창 새로고침해야됨..
AI) 무표정쨩 잡다한거
야짤
miso5
04/22 11851 59
(구매보급/자막판) 파탄절? 축하 동음 하나
소리
Ghost
04/22 15177 62
AI) 같은 배경에 여러 섹스 장면 넣는 방법 설명
야짤
miso5
04/22 10866 44
한번 더 과거글 찾아가서 G랄하면
일반
pst0025
04/22 2993 15
[미번/구매보급] RJ01588859 광기의 파도 소리 ~J○ 이종간 호러 독백 ADV~
미번
ArIso
04/22 20816 89
[보이스코믹][구매보급][한] 하게 해주는 근처 아이 EX
소리
책먹는망아지
04/22 17613 93
[AI번역] NTR전선/무한 네토라레 지옥
번역
봇치
04/22 63767 147
[Takota Konu] 여신 같은 여자친구
동인
ㅇㅇ
04/22 39314 183
天平キツネ EX25 은?랑
영상
참새
04/22 26036 94
[AI번역][미검수]퇴마사 헤레인과 악마들의 동굴_v1.01
번역
Treants
04/22 45719 152
은랑 - 뉴 게임 플러스 (스타레일)
영상
브레머튼
04/22 22242 109
[직번][Nakakazu] 깨끗하고 건강한 올바른 섹스
동인
qlkjrnd
04/22 33982 118
[구매보급][한국어 자막판][모녀덮밥]모녀의 금기에 젖은 비밀스런 타락 #보쌈 3P #처녀상실 #음란한 엄마
소리
이름뭐하지
04/22 15664 140
(코이카츠) - 최신 프리셋 일부 공유 [v2]
유틸
pst0025
04/22 10920 45
개껄리는데 번역 안된 것들 모음 (esuke 2, kanroame2)
동인
posan
04/22 20471 39
악령퇴산! 도와줘~! 색신님 노모자이크 패치
번역
stargaze
04/22 48400 202
[구매보급]존댓말○리 용사의 이세계 전생담 ~츤데레 용사와 달콤한 오호동거로 사랑을 키운 이야기~
소리
이름뭐하지
04/22 11283 53
[미번/번역요청]나만의, 선생님
동인
아돌
04/22 6310 17
프리렌 & 페른 갱뱅 short 영상 및 기타 루프 영상 2개
영상
브레머튼
04/22 43510 90
상업이용도 가능한 R18 음성 소재 1~12
소리
아라고나이트
04/22 9594 60
순애 LOVE✨숨소리✨가까운 거리✨작은 연하 천재 소녀의 사랑해…♡사랑해…♡키스✦시코시코✦페로페로→초사랑받는 섹스♡♡
소리
9ya
04/22 10366 77
전령희 레이시아 서클 신작진행28
정보
마검사리네최고
04/22 10436 20
청아) 나는 이런 투박한 그림체가 의외로 꼴림
야짤
루이즈 프랑소와즈
04/22 23083 41
미번, 번역요청-[KNUCKLE HEAD (Shomu)]-빼앗긴 유부녀 총집편
동인
netorare6974
04/22 15988 26
[대충 채색?] 안돼! 동거 라이프
복구
ddd86
04/22 44972 273
[konomi_mamura] 성교육 방송 「누나랑 할 수 있을까」
동인
agnet666
04/22 31369 69
[AI번역]온천 여관의 파이즈리 괴이 수정1
번역
솔라셀
04/22 38471 113
[Ai 후원] 세레나 [66p]
야짤
Ghost
04/22 12397 21
직번)[Shio Coffee] 출장 서비스를 불렀더니 다 들어주는 왕자님이 온 이야기
동인
qlalfsla
04/22 34855 226
orgy dice 1.0.3 업데이트 작업중입니다
작업현황
03030405
04/22 8044 25