kone
소미소프트

소미소프트

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

05/31/2025, 12:35:43
유틸
4047 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
오 신기하다
[미번/구매보급/번역요청] 비월선행록 스팀판 버전업 1.291
미번
giraffeman
05/15 40504 118
[농]거근 쥬지 두개 로 뷰지파괴 커미션
야짤
412343
05/15 11812 29
[복구] '카테니라& 머트 (수간') / '마키마 & 덴지 (체인소맨)' 영상 2개 복구
영상
브레머튼
05/15 19813 79
[ai번] 방과 후 아이 만들기 성교육 ~순수하면서 밝히는 발육 좋은 아이와 일대일 질내사정~
동인
latte
05/15 27427 125
[AI 번역][tsyatu] 관심있는 그 아이의 빗치같은 비밀
동인
히알룩스
05/15 22944 41
지금까지 해본 게임 개인적인 추천 ntr위주
후기 및 공략
tttyu
05/15 19044 32
ai)원신 스커크 선생님 참교육 2
야짤
ezmood
05/15 14551 68
[Healthyman] (청아,보테배) 이리야쨩을 완전동의 (최면) 하에 엄마로 만드는 야한 책
동인
밤하늘의신비
05/15 39918 162
[Healthyman] (청아) 그 아이는 아저씨의 여자
동인
밤하늘의신비
05/15 30769 126
ai) 움짤 몇개
야짤
Ghost
05/15 11756 33
스즈카의 고민 디테일 미쳤네
야짤
꼬냑
05/15 10622 20
[구매보급]진심사랑 프린세스 ~임신시키는 간청×유혹을 받아들인×신부 수업⇒쾌락 타락♪
소리
이름뭐하지
05/15 14026 66
(청아) 내 아내가 낳아준 아내
동인
밤하늘의신비
05/15 34734 87
어서오세요! 어린이 만들기 온천 마을 1.01 손번역 작업 이제 시작
작업현황
sjdwj
05/15 15168 66
부현 (스타레일)
영상
브레머튼
05/15 20675 65
[요청복구] My Girlfriend Advanced to the Dancer class and she buffs everybody v1.1r
복구
karuparu13
05/15 17616 31
[직번] [zonta] 내 엄마는 동급생의 젖소 노예
동인
maha1004
05/15 32866 58
[복구] 무녀나 짐승귀 관련 시리즈
복구
몬스터가아니다신이다
05/15 25317 45
ai, 찢) 야나기 부과장과 은밀한 성관계를 이어나갔다
야짤
kjh9304
05/15 7230 83
AI) GPT용 H 스테이터스 프롬프트를 더 개량했음
야짤
날개 로봇
05/15 14908 30
깐문지기 신캐구상 및 개발 방향
창작
sushi
05/15 7320 26
출시직전 신작 하나
정보
ksw112
05/15 13049 30
HC #248~268
영상
Yuzu
05/15 30028 198
원신 스커크선생님 쇼타따먹으려다 들켜서 참교육 (ai 176장 스압)
야짤
ezmood
05/15 17776 71
칸타렐라 (명조)
영상
브레머튼
05/15 15638 89
[Early Access] 힌덴부르크 (벽람항로)
영상
브레머튼
05/15 19385 108
레바테인의 욕망 (엔드필드)
영상
브레머튼
05/15 22323 81
AI) GPT로 뽑은 여주물 야겜 H 스테이터스 (프롬프트 추가)
야짤
날개 로봇
05/15 10858 28
[복구] 고전 명작 야애니 모음
영상
imakotou
05/15 21742 87
아리아드네 MZ 이식 102일 차 (주인공 디자인 및 EX 스토리 캐릭터 추가)
창작
Code_Max
05/15 12689 60