kone
소미소프트

소미소프트

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

05/27/2025, 09:41:09
유틸
2825 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
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
(청아)your mom 용 vrm 파일 2개
유틸
hamellton1144
01/08 11079 24
동급생2 리메이크 *DL Version* v1.0.2.0 크랙
유틸
핏짜허엇
01/07 11005 30
starmaker(스타메이커) 갤러리 모드
유틸
horseking94
01/04 35703 53
(01.07수정됨)슬레이 더 스파이어 (Slay the Spire) R18 모드 - Echidna (Ai 번역 + 손번역)
유틸
고기사장님
01/04 20496 60
언홀리 메이든 폭탄 증가패치
유틸
yuri88
01/04 14067 18
멀웨어 검사 스크립트 - 편집증 모드 추가 (DLL 전수조사)
유틸
moomin
01/03 8037 23
🔞 슬레이 더 스파이어 NSFW 모드 모음집 + 디펙트 리플레이서
유틸
Rasmodia
01/03 24710 56
⚠️⚠️멀웨어 탐지 스크립트⚠️⚠️ - 260104 수정
유틸
moomin
01/03 33228 128
카린즈 프리즌 개인모드공유
유틸
보바도사
12/31/25 18912 12
타락신관 조이플 언어설정+이미지 오류 해결파일
유틸
kimchi1234
12/31/25 10197 2
우리아이 판타지아 cGFzc2ZpbGU=
유틸
askted
12/30/25 4055 6
하급생리메이크 1.0.1패치+크랙
유틸
쿠로
12/28/25 14792 41
모카 러브 ReLive♪ ~진심 순애 거리에서의 절정 표정 관찰 + 귀여운 미소에 폭발 분사 애니메이션~ 노모파일
유틸
미스터장
12/27/25 19442 80
Anaertailin 작가의 Slay the Spire 일부 모드만
유틸
oobd69
12/26/25 16828 15
[후타]pernio의 후타나리 시리즈 노모패치 모음 + 복구 제한 안 두기로 했음
유틸
레가토
12/24/25 9658 20
darkest dungeon 성전사(crusader) 스킨
유틸
ine158cm
12/24/25 4461 11
음혈조복토에하 천박한 한글 데칼 공유
유틸
kkkkcccc
12/23/25 13978 46
언홀리 메이든 스탠딩 일러 노예 마스크 수정해 봄
유틸
5dk2io1
12/23/25 14553 30
[유틸] RJ01497368 라스트 스탠드 기번세트
유틸
Ghost
12/21/25 15525 34
용사 파티 무너뜨리기(Hero Party Must Fall) 0.6 회상방 개선 모드
유틸
이드씬
12/21/25 14283 31
시니시스타2 모드 노모 덮어쓰기 툴
유틸
sims9876
12/20/25 14008 15
통합노모모드 시니시스타2 (SiNiSistar2) 1.2.1 마지막... (25.12.24)
유틸
크로우
12/20/25 44139 131
[요청복구] 감옥용사 조이플 구동 패치
유틸
감비아
12/20/25 4831 9
ai로 만든 히토미 다운로더 kemono
유틸
skybleu
12/19/25 8684 9
신문고 인증) Brotli 텍스트 압축 및 해제 도구 사이트 소개
유틸
ㅇㅇ
12/17/25 4814 1
슬레이 더 스파이어 (Slay The Spire) R18 패치 복구 + 2 모드
유틸
cirial
12/15/25 28275 42
[유틸] RJ01389782 비밀 노출 -배덕의 달콤함에 물든 마나카 커스텀 미션 번역
유틸
kdhehejd
12/14/25 18447 25
촉수로 세뇌 1.00 CG버그 수정파일
유틸
Bulchevik
12/14/25 5250 13
윈도우 폴더 검색용 bat 파일
유틸
asdawv123
12/13/25 4213 -6
후타)[복구]잠꾸러기 후타나리의 착정던전 구출기 노모패치
유틸
레가토
12/03/25 5386 5