kone
소미소프트

소미소프트

유저스크립트 공유(업데이트250531)

05/31/2025, 12:35:43
유틸
4058 views · 2 likes

기능 1: 코네 메인 페이지 설명 펼치기/접기 기능 ( 모바일에 있길래 PC에서도 동작하게 수정)

1
1

기능2: 댓글창 좌클릭 잠금 버튼
댓글창에서 복사하거나 드래그하려고할때 대댓글창으로 자꾸 넘어가서 추천/비추천 우측에 자물쇠 버튼이 개별적으로 적용되어

기본적으로는 클릭시에 대댓글이 열리지않음, 자물쇠를 풀면 좌클릭 한번에 대댓글이 열림

1


// ==UserScript==
// @name         코네 유틸 
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  kone.gg 잠금버튼으로 답글 토글 (켜기/끄기): 기본적으로 댓글 클릭시 답글 안나오도록 & 메인페이지 토글 (접기/펼치기): 기본 접어두기
// @author       cloud67p
// @match        https://kone.gg/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    /***** [1] 댓글 관련 기능 *****/

    /****댓글 요소(commentEl) 옆에 잠금/해제 버튼을 추가하는 함수****/
    function addToggleButton(commentEl) {
        // 이미 버튼이 붙어 있으면 중복 추가하지 않기
        if (commentEl.querySelector('.reply-toggle-btn')) return;

        const btn = document.createElement('button');
        btn.textContent = '🔒';
        btn.classList.add('reply-toggle-btn');

        // 스타일 조정 (필요에 따라 위치/크기 바꿔도 무방)
        btn.style.marginLeft = '8px';
        btn.style.fontSize = '14px';
        btn.style.cursor = 'pointer';
        btn.style.background = 'transparent';
        btn.style.border = 'none';

        // 클릭 시 data-reply-enabled 토글 및 아이콘 변경
        btn.addEventListener('click', function(e) {
            e.stopPropagation();
            e.preventDefault();

            const enabled = commentEl.dataset.replyEnabled === 'true';
            if (enabled) {
                commentEl.dataset.replyEnabled = 'false';
                btn.textContent = '🔒';
            } else {
                commentEl.dataset.replyEnabled = 'true';
                btn.textContent = '🔓';
            }
        });

        // 댓글 엘리먼트 마지막 자식으로 버튼 붙이기
        commentEl.appendChild(btn);
    }

    function findReplyWrapper(commentEl) {
        const parentContainer = commentEl.closest('div.relative.pl-4.py-1\\.5');
        if (!parentContainer) {
            return null;
        }
        const sibling = parentContainer.nextElementSibling;
        if (!sibling) return null;
        return sibling.querySelector('#comment_write') ? sibling : null;
    }

    /**
     * 특정 댓글(commentEl)을 왼쪽 클릭했을 때,
     * data-reply-enabled="true" 상태가 아니면 원래 동작(대댓글창 열기)을 차단합니다.
     * 다만, 클릭된 요소가 버튼 또는 버튼 내부라면 차단하지 않습니다.
     */
    function disableClick(commentEl) {
        commentEl.addEventListener('click', function(e) {
            // 잠금 상태일 때만 처리
            if (commentEl.dataset.replyEnabled !== 'true') {
                // 클릭된 요소가 button 태그이거나, button의 자손인 경우—버튼 클릭은 허용
                if (e.target.closest('button')) {
                    return;
                }
                // 그 외(예: 댓글 텍스트 또는 빈 공간 클릭)는 차단
                e.stopPropagation();
                e.preventDefault();
            }
        });
    }

    /**
     * 한 댓글(commentEl)에 대해:
     * 1) 왼쪽 클릭 제한 (disableClick)
     * 2) 우클릭(contextmenu) 시 data-reply-enabled 속성을 토글 (true ↔ false)
     * 3) 댓글 옆에 잠금/해제 버튼 추가
     * 4) 대댓글창의 “취소” 버튼을 눌러도 대댓글창이 닫히도록 연결
     */
    function patchComment(commentEl) {
        // 이미 처리된 댓글이면 패스
        if (commentEl.dataset.replyPatched === 'true') {
            return;
        }
        commentEl.dataset.replyPatched = 'true';

        // 1) 왼쪽 클릭 제한
        disableClick(commentEl);

        // 2) 댓글 옆에 잠금/해제 버튼 추가
        addToggleButton(commentEl);

        // 3) 우클릭(contextmenu) 시 토글 로직 (기존에 있던 코드)
        commentEl.addEventListener('contextmenu', function(e) {
            e.preventDefault();
            e.stopPropagation();

            if (commentEl.dataset.replyEnabled === 'true') {
                commentEl.dataset.replyEnabled = 'false';
            } else {
                commentEl.dataset.replyEnabled = 'true';
            }
        });

        // 4) 대댓글창 “취소” 버튼 클릭 시 wrapper 닫기 (기존 코드)
        const wrapper = findReplyWrapper(commentEl);
        if (wrapper) {
            Array.from(wrapper.querySelectorAll('button')).forEach(btn => {
                if (btn.textContent.trim() === '취소') {
                    btn.addEventListener('click', function(ev) {
                        ev.stopPropagation();
                        ev.preventDefault();
                        wrapper.style.display = 'none';
                    });
                }
            });
        }
    }

    /**
     * 페이지 내 모든 댓글을 찾아 patchComment 실행
     */
    function patchAllComments() {
        document.querySelectorAll('.group\\/comment').forEach(patchComment);
    }

    /**
     * 댓글이 동적으로 추가/삭제될 때마다 patchAllComments 재실행
     */
    const observer = new MutationObserver(() => {
        patchAllComments();
    });
    observer.observe(document.body, { childList: true, subtree: true });

    // 초기 실행 (DOMContentLoaded 이후)
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', patchAllComments);
    } else {
        patchAllComments();
    }

    /***** [2] 환영 메시지 토글 복원 기능 *****/

    const esc = cls => cls.replace(/:/g, '\\:');

    function fixToggle() {
        document.querySelectorAll(`.overflow-hidden.max-h-32.${esc('md:max-h-none')}`)
            .forEach(el => el.classList.remove('md:max-h-none'));

        document.querySelectorAll(`button.${esc('md:hidden')}`)
            .forEach(btn => btn.classList.remove('md:hidden'));
    }

    fixToggle();

    const toggleObserver = new MutationObserver(fixToggle);
    toggleObserver.observe(document.documentElement, { childList: true, subtree: true });
})();
2
2 comments
05/31/25 Edited 05/31/25
추천, 수정,삭제도 우클릭 제한이 걸려있는 것을 확인하여 수정했습니다 현재 댓글을 좌클릭해도 답글 기능이 제한되어 페이지 위치조정등이 비활성화 되어있습니다. 각 댓글 영역의 우측상단 좌물쇠 버튼을 클릭하여 원래의 기능( 댓글 클릭 답글 및 페이지 위치조정 )이 활성화됩니다
05/31/25
오 신기하다
[구매보급]【전편 느긋한 오호】 쿨 오호 목소리 진심 오나위원과 참교육 진심 절정
소리
이름뭐하지
05/13 13229 74
[ai번역 - 노모] 세이카 여학원 공인 자지 아저씨 1~7
동인
mybest
05/13 30357 128
기번) Orange Piece 모음집 총 10개
번역
playthesean
05/13 34000 83
N.T.Resort에 오신 것을 환영합니다 신정보
정보
ㅇㅇ
05/13 14654 50
[구매보급] 바이러스님의 전신 해킹 쾌락 지배~ 속은 컴퓨터군은 바이러스 투성이♪~
소리
summer4552
05/13 12945 42
Ie 3갸루 단편
동인
SK
05/13 38984 276
【한국어 자막판】 섹스프렌드 겸임 친구 시리즈(2,3,4편)
소리
뒷담난쟁이로야족
05/13 18779 97
ntr레슨 후속작) ntr축구 체험판 공개 및 출시 d30
정보
머겅머겅
05/13 13997 20
[번역] 토끼 구멍
야짤
마법우엉
05/13 12733 82
[번역](청아)오빠는 퇴마인이 되어도 끝났다
동인
마법우엉
05/13 31600 106
[구매보급] [버전업] RJ01526327 어서오세요! 어린이 만들기 온천 마을 1.01
미번
gkqisq
05/13 18614 45
[기번/검수][iapoc]-유두 자극 레즈 에스테에 어서 오세요
동인
serdic
05/13 32701 145
[구매보급]【달콤한 오호】 성녀가 노예가 되어서 사봤다~ 조르게 하고 오호 목소리 섹스~
소리
이름뭐하지
05/13 22632 58
kajiking - 고도 카즈사 음문이 새겨지다 2.5
동인
qew123
05/13 24315 99
[버전업알림,손번역] 세뇌 어플 2 ver.1.2.1 (26.05.13)
번역
미스터장
05/13 47305 315
직번) [choukutetsushitsugan] 암퇘지 낙인
동인
qlalfsla
05/13 43139 278
AI, 셀레스포니아) 연구소의 인증 시스템
야짤
miso5
05/13 18438 96
[복구] 카프카 영상 복구
영상
브레머튼
05/13 17815 63
(오호고에/음어)雲八はち성우 작품 4개
소리
딸딸이의황태자
05/13 13991 66
[ai번역-노모 단행본] 가출 갸루랑 질내사정 잔뜩 해서 동거 생활 시작했습니다.
동인
mybest
05/13 25093 66
[알림] 비월선행록 이미지 번역 1.289 대응
번역
argoklarke
05/13 39241 116
[AI번역][RJ220780] 야리친 가정교사 네토리 보고 (패치파일만)
번역
호빵할배
05/13 38348 109
나오기를 ㅈㄴ 기대하는 작품
정보
존경합니다행님덜
05/13 13151 28
[RJ01624439] 뭔가 이야기가 있을 때는 "절대 혀를 내밀어야 해"라며, 포근한 메이드와 순수한 사랑을 나누는 달콤한 ‘키스 하메이드’ 생활
소리
돈이조아
05/13 12960 92
미번) 묘쌤은 이렇게 박혔다 3
동인
kjalar
05/13 21784 39
[재업/AI번역/riboshika][NTR] 자궁이 관통될 때까지♥︎
동인
gaymaster
05/13 26232 58
[밀프/쇼타/서양](보루토) 왕자지 보루토 : 사쿠라의 병원
영상
Ghost
05/13 40212 286
Church of Desires 손번역이 완료되었습니다.(후타, 음마화)[RJ01617031]
번역
sesv3030
05/13 56319 253
(구매보급,버전업,공식번역)세뇌앱2 ver1.2.1
번역
Gope
05/13 28874 210
[ai번역=오오토리 마히로] 나의 이세계 하렘 3
동인
mybest
05/13 21539 43