kone
소미소프트

소미소프트

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

05/27/2025, 09:41:09
유틸
2826 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
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
미번) 남친 있는 거유 알바 갸루와 실컷 섹스한 이야기3
동인
kjalar
05/24 9503 20
[미번][이종간][촉수][변형] 감염기록(RJ376909), If.(RJ01075511)
미번
roomonfire
05/24 8878 20
[언어없음] Ero-Electric Dreams ver.25.06.29
미번
미스터장
05/24 11652 33
[미번] 갓 딴 임신시키기 좋은 날 ver.1.1c (26.05.20)
미번
미스터장
05/24 8396 40
[미번] 이 풍속점에 서큐버스는 필요 없다 ~No succubus Wanted~
미번
미스터장
05/24 9671 28
구매보급) 【한국어판】 여동생이 나를 반찬삼아 자위하고 있었던 이야기
동인
GOOD
05/24 22674 66
자체한글 - 뒷계 까발린다! 러브호텔로 와라! 체험판 V2
번역
kkkkkk0909
05/24 31914 103
[미번] 01568399 patimon 마법학교 여학생의 고난…♡ ~소환수 슬라임에게 젖꼭지를 자극당하며 신음소리를 내며 연속 절정♡~ 모션 애니메이션
영상
ctf5r4edfyfdr4r4
05/24 24338 148
[Mogg] 처음하는 부활동
동인
ed123
05/24 12509 22
[후원/임신/출산/수간]GeulimYKUN - MAKIMA x HORSE IMPREGNATION
동인
bidurgi09
05/24 20216 81
[보급] RJ01558276 아크메시아 ~하렘 임신시키기 사냥꾼 생활~ [RPG Developer Bakin엔진]
미번
kkkkkk0909
05/24 14010 82
레이더 폭도들에게 공격당한 대공동 6과
영상
브레머튼
05/24 21276 109
[구매보급][번역요청][스캇] RJ148219 LAND OF THE FREE
미번
oo
05/24 6953 19
[요청복구]RJ01395769 기홍사 스칼렛~전설의 약초를 찾아~ver.1.05
복구
oo
05/24 19985 47
[복구] (RJ354108) 비타민퀘스트2 경량화(용량줄인) 업스케일링 판 (용량 대폭 할인! 48G >> 6.5G)
복구
sinbiru
05/24 21268 143
SKETCHY MASSAGE 추가 업데이트 진행사항안내
정보
kkkkkk0909
05/24 7221 27
[복구] 최면어플에 당한 의현 사부님 복구 영상
영상
브레머튼
05/24 18672 94
[구매보급][번역요청][버전업]RJ01521598)NAKED HIGHSCHOOL【学園生活露出RPG】
미번
냐냐퍄퍄
05/24 8179 36
[구매보급]추방된 현자의 성 인체 실험 ~연속 절정 어둠 마법 쾌락 연구~
소리
이름뭐하지
05/24 8731 59
와이즈 & 미야비 & 야나기
영상
브레머튼
05/24 13727 90
구매보급) 한국어판】 처음 하는 백합 섹스
동인
GOOD
05/24 13129 52
[요청복구?] 寅乃檻 써클 2개
복구
oo
05/24 19776 49
직번[Tourendou (Tonagi Tsuyu)]원나잇으로 끝나게 하지 않아 ~소꿉친구와 재회해서 연인이 되는 이야기~
동인
woo15
05/24 22006 117
데니아 (명조)
영상
브레머튼
05/24 16075 100
[요청복구] RJ201837 알프스와 위험한 숲 (KR, 노모)
복구
vhskorea
05/24 13673 49
촉수)유혈) 개인적으로 생각하는 촉수물 하이라이트
야짤
roomonfire
05/24 8870 28
ai) 오늘의 야짤
야짤
ai0098
05/24 7144 26
[후속편] 갱뱅 섹스 중에 최면이 풀려버린 의현 영상 (ZZZ)
영상
브레머튼
05/24 26046 148
[구매보급][번역요청][스캇] RJ098572 H -HARD CORE-
미번
oo
05/24 8903 21
직번]doji ro)처녀가 동정과의 첫 체험에서 눈을 뜨는 이야기 4
동인
woo15
05/24 25057 140