kone
소미소프트

소미소프트

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

05/27/2025, 09:41:09
유틸
2803 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
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
[복구] 란스03 노모패치
유틸
imakotou
04/28 16040 28
REC 리듬게임 추가 MOD
유틸
kunarin
04/28 7580 12
MZ MV data 복호화 실행기
유틸
미요포
04/27 13663 38
90일, RJ01540816 한정 복호화 도구) RMMZ JSON 통합 복호화 도구.pyw + RJ01540816 복호화.7z
유틸
ㅇㅇ
04/27 6544 6
제품 코드 추출기, 제품 코드 중복 찾기
유틸
ㅇㅇ
04/27 8548 18
MMD 모션,음악 통팩 공유
유틸
pst0025
04/26 9167 56
(코이카츠) 솔O티엘 작가 프리셋 통팩 공유
유틸
pst0025
04/25 12141 73
(코이카츠) 에러난 파일 복구 및 빠진거 보완
유틸
pst0025
04/25 10705 31
RPG MV/MZ 치트 플러그인 웹 딸깍 설치 오픈
유틸
mrpls
04/25 11374 28
자동소미 해적판의 해적판 업데이트
유틸
스눕제이크
04/23 8343 12
RPG MV/MZ 안실시간 미리번역 업데이트
유틸
mrpls
04/23 7823 27
파일 구글 번역기) kr_tr_7.pyw
유틸
ㅇㅇ
04/22 12274 9
(코이카츠) - "큰거"
유틸
pst0025
04/22 16060 66
(코이카츠) 큰거 올리기 전에 작은거
유틸
pst0025
04/22 18956 62
(코이카츠) - 최신 프리셋 일부 공유 [v2]
유틸
pst0025
04/22 10920 45
마나카 모드들
유틸
kkkktrrr
04/22 17172 33
(코이카츠) - 최신 프리셋 일부 공유
유틸
pst0025
04/21 10759 48
유틸) RJ코드 이미지 검색 용 기능추가
유틸
ATTAA
04/20 11990 9
VXA 스크립트) ▼ 素材(Materials) ## 한영이름 입력 스크립트.rb
유틸
ㅇㅇ
04/20 8694 7
RPG MV/MZ 실시간 번역기 딸깍 설치 웹사이트 오픈 (2.3 번역 주위 짤림)
유틸
mrpls
04/19 33302 106
(코이카츠) - グラフ 통팩 공유
유틸
pst0025
04/19 23162 56
유틸)유저스크립트-썸네일&본문 이미지 허용/비허용
유틸
cloud67p
04/19 7769 4
RPG MV/MZ 실시간 번역기 1.10 (루나와 음욕의 함정 던전, 젬마4)
유틸
mrpls
04/18 24752 35
VX or VXA 풀스크린 스크립트) ## VX Fullscreen++ Multi-Monitor.rb + ## VXA Fullscreen++ Multi-Monitor v2.32.rb
유틸
ㅇㅇ
04/18 9145 5
[노모패치, AI] 한 번만이라도 좋으니까, 나랑 해줘!
유틸
soxocel777
04/17 15255 29
자동 소미 해적판의 해적판
유틸
스눕제이크
04/17 9522 9
[복구]SecretFlasher.VoicePack-Plus 마나카 음성모드 개인수정(로우튠 등)
유틸
leedi
04/16 13353 7
( 코이카츠 ) - Anna anon 씬카드 공유
유틸
pst0025
04/16 24317 63
자동소미 해적판 업데이트
유틸
buttercookie
04/16 9440 12
[요청복구]스타바운드 통팩 모드만[구버전, 2024.06.17)
유틸
liberty
04/15 9699 1