하루종일 글 읽고 다시 전체 글목록으로 돌아가는데 좀 편하게 하고 싶어서 스크립트 싸옴
곧 고쳐질거같아서 과도기에나 잠깐 쓸법하여 그냥 코드로만 배포함
본인 css는 잘몰라서 그냥 대충 옆에 버튼 배껴 쓴거니까 잘못됐다 싶은건 classes 에서 삭제해서 사용하셈
greasemonkey, tampermonkey, violentmonkey 사용중이라면 아래 코드 임포트후 사용하면 되시겠다
무슨말인지 모르겠다면 무시
추가 >> ㅈㅅㅈㅅ 제일 아래에도 개념글 버튼이 있는 걸 모르고 리스트 상위에만 버튼 넣었음
버전 0.2로 업데이트 했읍니다
// ==UserScript==
// @name make all article button
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 전체 글 호출
// @match https://kone.gg/s/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
function buildButton() {
const classes = "focus-visible:border-ring aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:hover:bg-input/50 flex items-center justify-between gap-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 border-zinc-300 focus-visible:ring-1 focus-visible:ring-blue-500 dark:border-zinc-600 cursor-pointer !h-8 p-0 rounded-full bg-zinc-100 dark:bg-zinc-700 border-0 px-3";
return `<button data-slot="button" data-added="all" class="${classes}">전체글</button>`;
}
function getSubUrl() {
return location.origin + location.pathname.match(/^\/s\/[^\/]+/)[0];
}
function attachButton() {
const anchors = Array.from(document.querySelectorAll('a > button'))
.filter(btn => btn.textContent.includes('개념글'))
.map(btn => btn.parentElement);
if (!anchors.length) return false;
anchors.forEach(anchor => {
const btnParent = anchor.parentElement;
if (!btnParent) return;
if (btnParent.querySelector('button[data-slot="button"][data-added="all"]')) return;
const wrapper = document.createElement('a');
wrapper.href = getSubUrl();
wrapper.innerHTML = buildButton();
btnParent.insertBefore(wrapper, anchor);
});
return true;
}
const observer = new MutationObserver(() => {
attachButton();
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
})();
