kone
소미소프트

소미소프트

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

05/27/2025, 09:41:09
유틸
2821 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
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
로컬LLM(Ollama) 이용한 파이썬 MV 번역 코드
유틸
샤쿠
04/04 21882 21
[RJ01389782] [AI 번역] 비밀 노출 마나카 커스텀 미션 번역 [SekiMissions 8.5]
유틸
bunta_expert
04/04 11408 21
자동소미 해적판
유틸
buttercookie
04/03 7765 21
kio transfer 비번 자동입력
유틸
20250508
04/03 5179 22
Kone base64 auto-decoder
유틸
wef4r2
04/03 3633 6
코이카츠 버튜버 캐릭터 공유(v2)
유틸
pst0025
04/02 12005 53
눈동자 다운로더 GUI (아마도 최신버전)
유틸
하이바라
04/02 6119 16
[미번] 로제리움 ver.1.04 [RJ01515630] 회상방 버그 패치파일
유틸
awsdw
04/02 6639 12
코이카츠 야스씬 공유 - (홍차)
유틸
pst0025
04/01 13537 37
코이카츠 벽람 프리셋 공유(v2)
유틸
pst0025
04/01 15317 46
코이카츠 (?) 프리셋 공유
유틸
pst0025
04/01 16032 33
[Hoi Hoi Hoi]NTR은 모험에서 흔한 일이다 모바일 패치
유틸
qqwqq6666
03/31 5587 8
디코드 클릭하기 귀찮아서 만든 확장프로그램
유틸
20250508
03/31 10997 57
FontForge-2025-10-09-Windows-x64.exe + FontForgeBuilds 한글화.7z
유틸
ㅇㅇ
03/30 9504 6
RPGM VXA 스크립트) ▼ 素材(Materials) ## ゲーム画面倍率切替 - 멀티 모니터 대응 개선판.rb
유틸
ㅇㅇ
03/30 4866 2
celsector 탄약 치트 및 무기, 옷 해금 세이브
유틸
arcabuz
03/30 3522 11
Base 64 Encode Decode 확장 프로그램 업데이트 및 유저스크립트 방식 지원
유틸
shinyiro18
03/29 5385 12
PixivNavi - 픽시브 한손 탐색 스크립트
유틸
oroshinashi9
03/29 4521 7
(빅파이 개조만) 평범한 현실 남매 IN 섹스하지 않으면 나올 수 없는 방.[RJ01332822]
유틸
123551
03/29 8545 15
Base 64 Encode Decode 확장 프로그램 만들어 봤습니다.
유틸
shinyiro18
03/28 6555 18
코하루인가 이거 AI 이미지 번역기 괜찮은 것 같아서 링크 가져와봄
유틸
밀로아
03/28 4966 14
아오이짱 BepInEx 번역플러그인 잘리던거 해결봤다...
유틸
lalalala000
03/28 24247 59
(코이카츠) 시니시스타2 캐릭터 공유 - [리리아]
유틸
pst0025
03/27 20003 40
Deliriumベア@NTR 씬 공유 글에서 빠진 모드 추가
유틸
pst0025
03/27 4470 11
(코이카츠) 원신 캐릭터 공유
유틸
pst0025
03/27 10261 33
(코이카츠) 붕스 캐릭터 공유
유틸
pst0025
03/27 9980 38
데이터 클리너) czkawka - 크로키에트, windows_krokiet_on_windows_skia_opengl.exe
유틸
ㅇㅇ
03/27 11002 21
파이어 엠블렘 인게이지 - 모드 통합(+ 노모) 모드 만 있음
유틸
cumtree
03/27 3817 8
(RGVsaXJpdW3jg5njgqJATlRS) 코이카츠 씬 공유, 캐릭 포함
유틸
pst0025
03/26 9337 16
[후타]pernio의 후타나리 시리즈 노모패치 모음
유틸
레가토
03/26 5711 9