kone
소미소프트

소미소프트

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

05/31/2025, 12:35:43
유틸
3892 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
오 신기하다
[요청복구] RJ01414102 이상한 형무소와 음욕의 지하 미궁 ~빈틈투성이인 나나의 H한 프리즌 브레이크~
미번
retanya
05/26 7749 17
[AI 번역] [むきぐり工房] 언니에게 거유를 자랑하다 유출되서 혼쭐난 여동생
동인
ed123
05/26 14176 23
9시8분에 올라온 시골스키 근황
정보
sorbe123
05/26 4751 19
린네 Full 영상 (명조)
영상
브레머튼
05/26 16672 106
[신작] 카지노 (블아) 4k / 1080p
영상
브레머튼
05/26 27782 286
씨빨쏔쓰!!!!!!!!!
작업현황
ㅇㅇ
05/25 8033 54
5월 30일을 새로운 기념일로 지정합니다
정보
촉촉한촉수
05/25 9349 28
Mr. No Face 스파키x스파클
영상
참새
05/25 15308 105
AI 번역, 검수) Orange Piece 써클 10개 모음집
번역
playthesean
05/25 26479 103
90일, 2.33 GB) RJ262862 [神乳] 아일랜드 사가 -Island SAGA- v1.0.6 +.7z
복구
ㅇㅇ
05/25 15058 47
天平キツネ A39 밀티나
영상
참새
05/25 14564 96
[구매보급/자체한글] 세뇌앱2 apk
WOEAKE222
05/25 9414 64
[요청복구] [RJ282703] 출동! 전라풍기위원회
복구
ㅇㅇ
05/25 11909 26
900GB 3D VR영상 방주 공유
영상
ㅇㅇ
05/25 17049 76
청아) [atage] 편리한 오나홀로 길들이는 방법 1/5
동인
HJY
05/25 38569 206
[ai 번역] [Usagi Nagomu] The Everlasting Elf of the Evening - 유구의 창 엘프 1~6 [p.216]
동인
mybest
05/25 14269 57
관문지기 msg 작업 현황 - 5
작업현황
fin768
05/25 4737 29
[AI번역] [패치파일만] RJ224282 Spiral Legend V 1.51 수정v2
번역
dadskey
05/25 14591 57
[ai 번역][Usagi Nagomu] 황혼의 창 엘프 7~9 [p.118]
동인
mybest
05/25 13322 64
유부녀 세리아의 타락과 배덕 발매일 확정
정보
wouwouer
05/25 7537 34
[구매보급] RJ01271506 フォレスティア~ちいさな町の牧場ライフ~ 1.41 + 음성DLC 적용합본
미번
fbrpdlawm
05/25 21960 163
눈을 떠보니 목이 잘려 있는 여주인공
일반
mowajelly
05/25 6678 26
[ai 번역][Usagi Nagomu] 황혼의 창 엘프 총집편 에일린 파트 1 [p.137]
동인
mybest
05/25 16195 69
청아)zzz망상병 집단과 파티
영상
gal-joa
05/25 27018 87
소와 양의 잡화 상점 이미지 번역 기록 -3-
작업현황
5dk2io1
05/25 3154 23
[복구] 57eL5q+U44Om44Kt 25년 6월~
영상
cho980621
05/25 19331 117
a2FvZ3Vt 무삭제
영상
claire
05/25 33650 165
[미번/구매보급] [Isenori] 교실의 그 아이는 인간을 그만둔 젖소가슴 변기녀 20
동인
ㅇㄹㅋㄴ
05/25 8039 16
[미번/구매보급] [Isenori] 음침한 여동생을 『교육』해서 쾌락 중독의 육변기로 만든다 29
동인
ㅇㄹㅋㄴ
05/25 8715 15
[Pistonring Nishizawa] 갸루랑 미친 듯이 노콘질싸 섹스하는 이야기 #6
동인
1uF
05/25 17909 92