kone
소미소프트

소미소프트

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

05/31/2025, 12:35:43
유틸
4065 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
오 신기하다
[번역요청] [Yoshizou888] NTR 판타지 - 부패와 지배의 연쇄
미번
Ed
05/04 13690 35
Comfyui 재밋내
야짤
zerocoke
05/04 8826 17
[어린이날 기념 복구] RJ150996 마립 서큐버스 요마원 1.6
복구
blackmalangcalf
05/04 37473 68
[AI번역] 역겨운 거근 아저씨가 여자친구를 네토라레하는 이야기! 거근이 최고!
동인
gkcuwuwlltnnrra
05/04 22619 66
어린이날 기념,후원보급) meatloaf 2024/4 ~2026/4
영상
쩝냡
05/04 27302 159
(청아 gif) 나는 빵빵단인데 이거 페도임
야짤
hannanas
05/04 16093 31
염월선행록 translation-cache.log 5월10일자 갱신 마지막
유틸
보바도사
05/04 8875 39
직번)[transistor baby]성재의 처녀 아스트레이아1~4편
동인
돋돋돋돋돋
05/04 25013 86
문제가 됐던 파일 및 암호화 관련 내용
정보
미스터장
05/04 10083 53
(한글자막) 친구네 집 메이드가 너무 내 취향이라서, 내 암컷으로 만들어버렸습니다
영상
꽃사슴
05/04 28784 185
[구매보급] [AI 번역] [개조버전] 견습 모비와 순풍을 기다리는 섬 RJ01042745
번역
V
05/04 36534 219
[미번] RJ01549336 알미오시온의 의술사 アルミオシオンの医術師 v1.00
미번
핏짜허엇
05/04 37298 172
[ai딸깍번역]동경하는 스승의 복제체 상대로 하고 싶었던거 전부 하는 이야기
동인
rlans
05/04 42350 315
[구매보급] 마조 시바키 라디오 시리즈 (1~3)
소리
summer4552
05/04 8140 42
후기) 색귀, 쯔꾸르 역사상 goat.
후기 및 공략
parmisgood
05/04 9402 31
횡령을 들켜 상사가 시키는 대로 하게 되는 경리 1p
야짤
요요코코
05/04 11617 29
[복구] RJ105442 암즈 디바이서 (arms devicer) v1.4 KR
복구
meruna00
05/04 15826 60
청아, AI번역) [직번] 구축함 하츠유키 이야기 (Wancho)
동인
rapbit
05/04 10094 22
minus8) 효과음 추가
영상
rlans
05/04 21617 97
(로리/임신) 아크메시아 발매일 결정!
정보
라임무르
05/04 14068 18
90일, 미번+번역) RJ425610 마도술사 미사
복구
ㅇㅇ
05/04 21631 56
[アブジャン] 레나쇼타 ー디지케모 누나와 H한 합체ー
영상
cupapan
05/04 24229 45
90일) RJ195455 미츠루기 코토노가 변태가 되어 버린 이야기 v1.10.7z
복구
ㅇㅇ
05/04 21504 37
(구매보급,버전업)RJ01613299 음최도시 휴포니즘
미번
gkawkek23
05/04 12758 44
[직번] Nunnu) - 좋아하는 미라이가 다른 녀석 책상에서 모서리 자위라니 말도 안 돼
동인
유의
05/04 24011 150
[직번] [Yesman] 잘생긴 왕자님 스타일 여자 AV타락 인생종료편
동인
maha1004
05/04 27203 75
[구매보급] [번역요청 시크릿 바이스 ~이계의 낙원~
미번
howl17
05/04 13102 27
미번에 올라왔던 문제의 파일 구동 해봤음
정보
미스터장
05/04 11722 43
보지고등학교 야짤 시리즈 모음
야짤
berryzz
05/04 18184 84
[구매보급]신성한 발키리의 굴욕 더러운 자지 청소
소리
이름뭐하지
05/04 12042 60