념글 구분하기 힘들어서 내가 쓰려고 gpt한테 부탁함
// ==UserScript==
// @name 제목에 별 추가 (좋아요 15 이상)
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 좋아요 수가 15 이상이면 제목 앞에 별 이모지(⭐️) 붙이기
// @match *://kone.gg/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
// DOM 변화 관찰 함수
function updateContents() {
document.querySelectorAll('.contents').forEach(content => {
const likeDiv = content.querySelector('div.flex.gap-1.text-red-500');
if (likeDiv) {
const titleSpan = content.querySelector('span.overflow-hidden.text-nowrap.text-ellipsis');
if (titleSpan && !titleSpan.textContent.trim().startsWith('⭐️')) {
titleSpan.textContent = '⭐️ ' + titleSpan.textContent.trim();
}
}
});
}
// 초기 페이지 로드 시 실행
window.addEventListener('load', updateContents);
// MutationObserver 설정
const observer = new MutationObserver(() => {
updateContents();
});
// 대상 DOM 요소와 관찰 옵션 설정
observer.observe(document.body, {
childList: true, // 자식 요소가 추가되거나 삭제되는지 확인
subtree: true, // 전체 DOM 트리를 확인
attributes: false, // 속성 변화는 무시
characterData: false // 텍스트 노드 변경은 무시
});
})();
