kone
소미소프트

소미소프트

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

05/31/2025, 07:46:47
유틸
1832 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
이것저것 만져봤는데 제 능력부족으로 댓글창만 새로고침만 하는건 안되더라구요 ㅠㅠ 최신순/등록순 버튼으로 댓글창 새로고침해야됨..
오바와치)주노의 첫경험
창작
simplelife
05/07 13774 18
【7종 극강 핥기】✅귀핧기에 열중하는 엘프 공주 ~ 끈적 · 통 통 · 귀 안쪽 깊숙히 · 귀 페라 · 위스퍼 · 고속 · 양쪽 귀 동시 · 마지막은 노콘 섹스♪~
소리
maruran
05/07 17080 151
[기번/임시] REC 0.5.2.1
번역
kts
05/07 35755 126
[번역] [셀프구속/치비] [Icoicoikoi] 금기의 사슬에 구속된 이 몸이 심연에서 홀로 종언을 고하는 이야기 ~셀프구속자위를 해 봤다가 점점 쾌락의 늪에 빠져버렸다~ (트릭컬)
동인
yjgtiihty
05/07 19011 111
[기계번역/자동번역] NTR Mobile [v0.23.0]
번역
karuparu13
05/07 49019 77
[RJ01582349][AI 자막만]슨도메와 루인드를 5번씩 견디면 뇌가 저릿해지는 사정을 시켜주는 멘즈 에스테
소리
creatine
05/07 10260 51
[Monchan Rev3] 보지 대주시겠습니까?
동인
ㅇㅇ
05/07 34426 144
구매보급) 나쁜 여기사가 귀여운 남자아이를 레〇프 해버리는 이야기
동인
GOOD
05/07 18577 86
AI, 셀레스포니아) 커피숍에서 일하는 아마네
야짤
miso5
05/07 13636 127
[구매보급][번역요청]AI) No Tomorrow Rebellion
미번
마카라이트
05/07 9344 26
[후원업뎃/미번/이종간/촉수/수간?]La Vitalis : Immortal Loss 0.47 노모
미번
루파조아
05/07 11516 37
RJ353573) 아이스 하트와 잭오 v1.10 [기계번역]
복구
everywhere
05/07 22645 68
님포 5월 정보
정보
우욿
05/07 19763 21
ai,스압)어라 저거 우리반 반장아냐?
야짤
gpsel157
05/07 12343 59
[Orico] 가정 속 매춘 1~3
동인
1uF
05/07 28254 87
[알림] 비월선행록 이미지번역 빼먹은 거 두 장 있길래 추가함
번역
argoklarke
05/07 23546 81
소악마 스마트폰작업중
작업현황
toung
05/07 4507 17
[AI번역][Torotarou] Shoujo Fondue - Sweet Girls Sex Diary | 少女性愛日記 (decensored)
동인
mybest
05/07 12539 53
[ VAM ][ 퍼리 ] 프레디 나이트 클럽 - FEXA
영상
s99a99
05/07 25519 55
NTR) 타락한 성흔 7월로 발매 연기
정보
drogba
05/07 9038 34
天平キツネ V38 데니아
영상
참새
05/07 22075 140
[요청복구] RJ080939 섬격의 기어 (손번역)
복구
이상성애
05/07 19159 62
자동소미 해적판X2 1.0.4업데이트 알림
유틸
스눕제이크
05/07 6566 18
[AI번역][Makosho] Mujintou de, SEX ni Kyoumi Shinshin na Dosukebe InCha Joshi-tachi to Harem Life (decensored)
동인
mybest
05/07 27692 98
[버전업 알림] 음최도시 휴프노즘 1.04 번역 적용완
번역
saika
05/07 31681 126
[★추천] 무료 망가 번역기★
유틸
mybest
05/07 27867 127
RJ01549336 알미오시온의 의술사 퀘스트, 목적? 일부 - 미검수, 비전문가, 오역 다수
번역
wkwlqhwltprtm
05/07 36448 105
[버전업] [구매보급] RJ01588884 이노센트 도터 v1.1.0
미번
gkqisq
05/07 10114 41
구매 보급/번역요청)RJ336598 로스트 메모리 사가 1.3.5 ,【夢幻の迷宮】2번 그리고 덤
미번
ldg398224
05/07 13209 45
[take_shinshi] 속아넘어가기 쉬운 내 아내는…
동인
agnet666
05/07 27019 53