kone
소미소프트

소미소프트

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

05/27/2025, 09:41:09
유틸
2963 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
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
당근 새끼 제작근황 ㅋㅋㅋㅋㅋㅋㅋ
정보
여동생킬러
05/01 14943 31
[미번, 복구]アナル触手ゲーム 捕らえた魔法使いのケツ穴で卵を育てろ!!
미번
ruel-x
05/01 17131 38
【유부녀 음란 보지 네토리】 연애 풍속 diary 유부녀 바니걸 소프 아가씨 미츠하의 덥수룩한 음모 보지
소리
shiroi
05/01 14316 100
[기번] RJ01310014 Caught a Cat Miko! ~Live2D Tentacle Game
번역
FGFFG0829
05/01 47387 144
[후타] 프리렌 & 아우라
영상
브레머튼
05/01 30055 129
[충간] 벨 & 니콜 & 비비안 - 비치 파티
영상
브레머튼
05/01 16745 61
[미번/구매보급] 사랑하는 선생님에게 젖꼭지 고문당하는 소녀 (愛しの先生に乳首責めされちゃう女の子)
미번
nxsolo
05/01 15723 42
염월선행록 한패 나올 때 까지 숨 참는다
일반
nxsolo
05/01 7968 34
[AI번역/이미지번역] 마도사 카나데의 후타나리 던전 Quest V1.2 KOR
번역
jpjp112
05/01 49050 233
(AI번역,미검수)(후타나리, 펨보이, 후타나리 NTR) Futa Familly 0.245
번역
Onko
05/01 44707 116
[구매보급][한국어 자막판][지뢰계×러브러브×신음]병들고 연약한 아리아짱에게 무너지다. 언제 어디서든지 러브러브한 섹스
소리
민초드래곤
05/01 8987 86
염월선행록 하는 법
정보
mdabedlehm
05/01 12611 21
[Sevengar] 갈색 쿨계 코스녀, 감사제 후 반성 벌칙 섹스
동인
ll사사라ll
05/01 26968 92
[미번/번역요청] 야리나리 ヤリたければ、ナリあがれ! RJ01249935
미번
rlans
05/01 9990 52
mmd 자작 영상
영상
pst0025
05/01 14864 59
사이클론 신작 게임 정보 간단요약
정보
ㅇㅇ
05/01 10054 31
[ai번역]ムチ肉ヘブンでパンパンパン + イラストカード
동인
doumaro
05/01 23207 65
야앵기담 근황
정보
sorbe123
05/01 5627 17
[ai번역]あなた…ごめんね。私…ホントの幸せ見つけちゃった。
동인
doumaro
05/01 20651 48
[ai번역]KNUCKLE HEAD寝取られ人妻総集編
동인
doumaro
05/01 17239 66
(미번, AI, NTR) [Shirokurosuki] 포니테일쨩은 애널에 지지않아! 1, 2
동인
츠바키미유
05/01 18354 35
minus8) 효과음 추가
영상
rlans
05/01 22302 89
[SG9seUNjQ2M=] Your Secret Memory 01~12
영상
류제로
05/01 24049 87
90일, 2.24 GB, 본문 참조, 추가 복구 없음) FZ d_728516
복구
ㅇㅇ
04/30 27134 60
[ai번역]クール系年上バリキャリ彼女 尊厳破壊和姦 1-2
동인
doumaro
04/30 15857 51
[ai번역]Ibitsu Seiso na Yowa Ki Kanojo Gouin Motokare ni Netorareru_. _ Una ragazza pura ma infedele
동인
doumaro
04/30 21793 56
[ai번역]Boku no Suki na Kyonyuu Osananajimi ga Charao Senpai no Kanojo ni Natta Hi 2(ai翻译)
동인
doumaro
04/30 9532 25
[ai번역]Boku no Suki na Kyonyuu Osananajimi ga Charao Senpai no Kanojo ni Natta Hi
동인
doumaro
04/30 15927 24
[ai번역]Yokyuu Fuman na Hitozuma ga Gym de Shiriatta Wakai Otoko ni Netorareru Hanashi _ 欲求不滿的人妻被健身房認識的年輕男人強睡奪走的故事
동인
doumaro
04/30 15396 36
[ai번역]ojousama senshi nooburu ~icharabu sais○ nante ariemasen wa~
동인
doumaro
04/30 27819 86