kone
소미소프트

소미소프트

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

05/31/2025, 07:46:47
유틸
1771 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
이것저것 만져봤는데 제 능력부족으로 댓글창만 새로고침만 하는건 안되더라구요 ㅠㅠ 최신순/등록순 버튼으로 댓글창 새로고침해야됨..
takeyuu 부잣집 갸루가 내 이성을 파괴해서 질싸 시키기까지
동인
SK
05/14 46853 224
[요청복구] 크로네의 기분 - 별 내리는 마을의 마녀 견습
복구
ulul2684
05/14 34233 38
[요청복구] RJ356209 청아) 동물 귀☆트레이닝 ~광폭한 동물귀 아가씨 조교 트라이얼~ ver.1.0.10
복구
Ghost
05/14 27811 33
TU1EdHlwZTg3 모음집 업데이트 알림
영상
hannanas
05/14 21490 37
커오메 회사 신작 커스텀 로맨스 시티 8월 28일 발매 예정
정보
돔마
05/14 15897 24
[구매보급][번역요청] RJ01627306 よこしま修行村 요코시마 수행마을
미번
cjweoic214
05/14 21347 66
eGlhbmd3ZWl0dWRvdQ 23년 모음
영상
karatro
05/14 24718 93
(코이카츠) 학원마스 프리셋 공유
유틸
pst0025
05/14 15669 43
[벽람항로] 다이호 (기본 + 누드)
영상
브레머튼
05/14 26724 122
[AI 번역][Shiv] 내가 아는 학생 회장이 아니었다
동인
히알룩스
05/14 20665 48
(코이카츠) 프리셋 공유
유틸
pst0025
05/14 11568 58
[버전업][번역요청] No Tomorrow Rebellion 1.03
미번
마카라이트
05/14 15791 19
[보이스코믹][구매보급][한] 여자 사진부와 아저씨 지도원 2
소리
책먹는망아지
05/14 12276 83
eGlhbmd3ZWl0dWRvdQ 22년 모음
영상
karatro
05/14 21883 77
[후남,미번]후타나리 조카 리아라쨩
동인
jinys9810
05/14 13519 17
AI) 무표정쨩 레이프
야짤
miso5
05/14 14460 81
[이종간 / 청아] 6J6e6J+75LiK5qCh 작가 모음
영상
yozuna
05/14 34145 106
[고전/레이프/BDSM/group] pretty pridot 통합버전
영상
미노타쿤
05/14 28410 206
직번) ※취향주의 [John K. Pe-ta] 어떡해가 멈추질 않아 + 선생님 완전 쉽네♥
동인
qlalfsla
05/14 24912 58
eGlhbmd3ZWl0dWRvdQ 21년 모음
영상
karatro
05/14 27300 68
타락신관: 여동생과 악마의 혈통(+DLC) 세이브
세이브
NF레쉬
05/14 21219 47
Cyclone) 벌써 29도라니 더우니까 아이스께끼~
야짤
drogba
05/14 14985 31
[자체한글] 상식개변 시뮬레이터 -최○ 앱으로 좋아하는 그 아이와 연인이 되자 v1.016
번역
하우두유두
05/14 110871 340
[구매보급]모녀덮밥. 싱싱한 백보지 딸과 보지털 수북한 부인한테 내 마음대로 사정♪
소리
이름뭐하지
05/14 11591 66
힘과 쾌락의 융해
소리
grebiy
05/14 18639 54
은랑 LV.999 (스타레일)
영상
브레머튼
05/14 16440 105
(최신화) [미번] 밀옥 전편 v1.5 (26.04.25) >> godot엔진추정
미번
kkkkkk0909
05/14 18931 37
그레이스 (ZZZ)
영상
브레머튼
05/14 19014 103
[구매보급][번역요청] 뒤쪽의 흥신소
미번
minki
05/14 18025 20
ai, 원신) 만취한 시틀라리를 침실로 데려가 잔뜩 섹스했다
야짤
kjh9304
05/14 20410 115