kone
소미소프트

소미소프트

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

05/27/2025, 09:41:09
유틸
3004 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
아 근데 지금 해보니까 게시판에 들어와서 새로고침을 한번 해줘야 버튼이 바뀝니다;; 참고해주세용
ㄴ수정했습니다 혹시 처음에 받으신 분 있으시면 다시 써주세용
오바와치)주노의 첫경험
창작
simplelife
05/07 13774 18
【7종 극강 핥기】✅귀핧기에 열중하는 엘프 공주 ~ 끈적 · 통 통 · 귀 안쪽 깊숙히 · 귀 페라 · 위스퍼 · 고속 · 양쪽 귀 동시 · 마지막은 노콘 섹스♪~
소리
maruran
05/07 17080 151
[기번/임시] REC 0.5.2.1
번역
kts
05/07 35755 126
[번역] [셀프구속/치비] [Icoicoikoi] 금기의 사슬에 구속된 이 몸이 심연에서 홀로 종언을 고하는 이야기 ~셀프구속자위를 해 봤다가 점점 쾌락의 늪에 빠져버렸다~ (트릭컬)
동인
yjgtiihty
05/07 19011 111
[기계번역/자동번역] NTR Mobile [v0.23.0]
번역
karuparu13
05/07 49019 77
[RJ01582349][AI 자막만]슨도메와 루인드를 5번씩 견디면 뇌가 저릿해지는 사정을 시켜주는 멘즈 에스테
소리
creatine
05/07 10260 51
[Monchan Rev3] 보지 대주시겠습니까?
동인
ㅇㅇ
05/07 34426 144
구매보급) 나쁜 여기사가 귀여운 남자아이를 레〇프 해버리는 이야기
동인
GOOD
05/07 18577 86
AI, 셀레스포니아) 커피숍에서 일하는 아마네
야짤
miso5
05/07 13649 127
[구매보급][번역요청]AI) No Tomorrow Rebellion
미번
마카라이트
05/07 9344 26
[후원업뎃/미번/이종간/촉수/수간?]La Vitalis : Immortal Loss 0.47 노모
미번
루파조아
05/07 11516 37
RJ353573) 아이스 하트와 잭오 v1.10 [기계번역]
복구
everywhere
05/07 22646 68
님포 5월 정보
정보
우욿
05/07 19763 21
ai,스압)어라 저거 우리반 반장아냐?
야짤
gpsel157
05/07 12348 59
[Orico] 가정 속 매춘 1~3
동인
1uF
05/07 28254 87
[알림] 비월선행록 이미지번역 빼먹은 거 두 장 있길래 추가함
번역
argoklarke
05/07 23546 81
소악마 스마트폰작업중
작업현황
toung
05/07 4518 17
[AI번역][Torotarou] Shoujo Fondue - Sweet Girls Sex Diary | 少女性愛日記 (decensored)
동인
mybest
05/07 12539 53
[ VAM ][ 퍼리 ] 프레디 나이트 클럽 - FEXA
영상
s99a99
05/07 25519 55
NTR) 타락한 성흔 7월로 발매 연기
정보
drogba
05/07 9038 34
天平キツネ V38 데니아
영상
참새
05/07 22075 140
[요청복구] RJ080939 섬격의 기어 (손번역)
복구
이상성애
05/07 19159 62
자동소미 해적판X2 1.0.4업데이트 알림
유틸
스눕제이크
05/07 6568 18
[AI번역][Makosho] Mujintou de, SEX ni Kyoumi Shinshin na Dosukebe InCha Joshi-tachi to Harem Life (decensored)
동인
mybest
05/07 27692 98
[버전업 알림] 음최도시 휴프노즘 1.04 번역 적용완
번역
saika
05/07 31682 126
[★추천] 무료 망가 번역기★
유틸
mybest
05/07 27873 127
RJ01549336 알미오시온의 의술사 퀘스트, 목적? 일부 - 미검수, 비전문가, 오역 다수
번역
wkwlqhwltprtm
05/07 36448 105
[버전업] [구매보급] RJ01588884 이노센트 도터 v1.1.0
미번
gkqisq
05/07 10120 41
구매 보급/번역요청)RJ336598 로스트 메모리 사가 1.3.5 ,【夢幻の迷宮】2번 그리고 덤
미번
ldg398224
05/07 13209 45
[take_shinshi] 속아넘어가기 쉬운 내 아내는…
동인
agnet666
05/07 27019 53