kone
소미소프트

소미소프트

개념글/전체글 버튼 분리 스크립트(수정)

05/27/2025, 09:41:09
유틸
2804 views · 3 likes

스크립트 지식 1도없이 챗지피티로 만들었습니다~ 문제시 글삭함

오류 생기면 스크립트 삭제 추천드려요



1

원래 이렇게 붙어있던 개념글/전체글 버튼을



1

이렇게 분리했습니다. 왼쪽은 전체글 모드, 오른쪽은 개념글 모드


그리고 중요한건 전체글일때 전체글 버튼 누르면 전체글 새로고침됨

마찬가지로 개념글일때 개념글 버튼 누르면 개념글 새로고침됨

새로고침 할려고 버튼 나눈거임


하 근데 최신순(시계모양) 버튼이 버튼 오른쪽에서 왼쪽으로 가버림.. 이건 못고치겟서


1

게시판 하단에 있던 버튼도 바뀝니다


1
1

확장프로그램 템퍼몽키 설치하시고 새 스크립트 만들기 > 안에 내용 지우고 스크립트 복붙 > 저장




아래는 스크립트 코드

// ==UserScript==
// @name         kone.gg 개념글/전체글 버튼 삽입(수정판)
// @namespace    http://tampermonkey.net/
// @version      2.4
// @description  게시판 개념글/전체글 버튼 삽입 수정
// @match        https://kone.gg/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let lastUrl = location.href;

    const createButton = (text, onClick, isActive) => {
        const button = document.createElement('button');
        button.textContent = text;
        button.style.cssText = `
            margin-right: 8px;
            padding: 6px 12px;
            border: none;
            border-radius: 9999px;
            font-size: 14px;
            cursor: pointer;
            background-color: ${isActive ? '#dc2626' : '#e4e4e7'};
            color: ${isActive ? 'white' : '#27272a'};
        `;
        button.addEventListener('click', onClick);
        return button;
    };

    const insertButtons = () => {
        const url = location.href;
        const isHot = url.includes('mode=hot');
        const basePath = location.pathname;

        const boardWrapper = document.querySelector('div.grow.flex.flex-col.rounded-b-lg');
        if (!boardWrapper) return;

        const buttonRows = boardWrapper.querySelectorAll('div.flex.items-center.gap-2');
        if (!buttonRows.length) return;

        buttonRows.forEach((targetRow) => {
            if (targetRow.querySelector('a[href*="write"]')) return;
            if (targetRow.querySelector('#custom-btn-hot') || targetRow.querySelector('#custom-btn-all')) return;

            // 기존 개념글/전체글 a 링크 삭제
            targetRow.querySelectorAll('a[href]').forEach(link => {
                const href = link.getAttribute('href');
                if (href.includes('mode=hot') || href === basePath) {
                    link.remove();
                }
            });

            const hotBtn = createButton('개념글', () => {
                window.location.href = basePath + '?mode=hot';
            }, isHot);
            hotBtn.id = 'custom-btn-hot';

            const allBtn = createButton('전체글', () => {
                window.location.href = basePath;
            }, !isHot);
            allBtn.id = 'custom-btn-all';

            targetRow.appendChild(allBtn);
            targetRow.appendChild(hotBtn);
        });
    };

    // 버튼 삽입 및 재삽입 시도
    const tryInsertButtons = () => {
        insertButtons();
    };

    // history API 훅 감싸기
    const hookHistoryMethod = (method) => {
        const original = history[method];
        return function () {
            const result = original.apply(this, arguments);
            window.dispatchEvent(new Event('locationchange'));
            return result;
        };
    };
    history.pushState = hookHistoryMethod('pushState');
    history.replaceState = hookHistoryMethod('replaceState');

    window.addEventListener('popstate', () => window.dispatchEvent(new Event('locationchange')));
    window.addEventListener('locationchange', () => {
        if (lastUrl !== location.href) {
            lastUrl = location.href;
            tryInsertButtons();
        }
    });

    // DOM 변경 감지해서도 버튼 갱신 (최상위 body 감시)
    const observer = new MutationObserver(() => {
        tryInsertButtons();
    });
    observer.observe(document.body, { childList: true, subtree: true });

    // 최초 실행 딜레이 줘서 기다렸다 삽입
    setTimeout(() => {
        tryInsertButtons();
    }, 1000);

})();
3
2 comments
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
[유틸] [노모] 비밀 노출 -배덕의 달콤함에 물든 마나카- 노모패치 v1.0.0.6
유틸
Ghost
06/15/25 14122 15
업뎃) 스텔라블레이드 릴리 누드모드
유틸
konekat
06/14/25 18502 65
[업뎃알림] 오토소미
유틸
김머시기
06/12/25 10964 34
야식메뉴판 업뎃해옴 - 2.0.0
유틸
qqoro
06/12/25 13804 70
RPGMVP 파일을 포토샵으로 열고 수정하고 저장하장!!!!!!!!!!!!!!!!
유틸
moomin
06/12/25 4867 17
코네 유저 메모 및 차단 스크립트
유틸
글쓴이
06/11/25 6475 17
[노모패치] 졸린 유대감 ver.1.2.1
유틸
77777
06/10/25 10256 29
[RJ01367733] 요정의 물약 공장 기번 유틸
유틸
takodachi
06/09/25 2879 6
시니시스타 2 모드 모음
유틸
sims9876
06/09/25 12353 33
[2025-06-20] 게시글 url 추출
유틸
kts
06/09/25 2706 3
시니시스타2 알몸폭유모드
유틸
ㅇㅇ
06/08/25 13418 37
히토미 다운로더용 kone 이미지 일괄 다운로드 스크립트
유틸
글쓴이
06/08/25 7536 31
메스가키 새여동생♡낮져밤져 유혹섹활 AI노모
유틸
물크스
06/08/25 9993 77
.RPGMVP .PNG_을 반디뷰에서도 열어보장
유틸
moomin
06/07/25 4790 11
동인탭 글 숨기는 스크립트(수정v2)
유틸
딸기맛농축함유🍓
06/07/25 3112 2
야겜 모드 모음
유틸
나나바
06/06/25 9778 4
(긴급!)유니티 제미니 AI 자동번역 딜레이 대폭수정및 검열회피(반드시 새로 받아야함)
유틸
알탕
06/05/25 15303 33
코네 wide 모드
유틸
arcjay
06/05/25 3665 10
유니티 (AutoTranslator) 제미니 AI번역기 무료 API 다중추가 삽입및 번역 재시도 기능 추가
유틸
알탕
06/04/25 9288 23
[업뎃] Auto Somi 자동 국룰입력/복호화/다운로드/미리보기 등
유틸
김머시기
06/04/25 14992 53
(수정) 유니티 자동번역기(autotranslator) 제미니 ai (Gemini) 번역하기 풀세트
유틸
알탕
06/02/25 38542 87
[코네 스크립트] 단축키 변경 및 추가 / 다운로드 버튼 추가 / 사이트 색상 변경(이상함) [250603]
유틸
유령
06/02/25 3364 13
txt - csv 변환기
유틸
팰애호단체
06/02/25 2591 5
썸네일 크기조절 스크립트
유틸
딸기맛농축함유🍓
06/01/25 3014 4
던전 앤 브라이드 파밍 치트 공유 (20250601 17:16 수정)
유틸
rengester
06/01/25 6294 7
몬스터 블랙마켓 (몬블마) 브리딩 모드 한글 번역판(25.06.09 수정)
유틸
이노
05/31/25 11720 7
직접 만든 던전 앤 브라이드 모드 패치 공유
유틸
rengester
05/31/25 5179 10
유저스크립트 공유(업데이트250531)
유틸
cloud67p
05/31/25 3869 2
댓글 자동확장 개선 스크립트
유틸
딸기맛농축함유🍓
05/31/25 2368 6
댓글 최신순/등록순 버튼 분리(댓글 새로고침) 스크립트
유틸
딸기맛농축함유🍓
05/31/25 1678 2