// ==UserScript== // @name 나무위키 광고 삭제 // @namespace Violentmonkey Scripts // @icon https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://namu.wiki // @match https://namu.wiki/* // @run-at document-end // @grant none // @version 1.02 // @author Xlbatross // @description 2025. 3. 26. 오후 12:35:46 // @downloadURL none // ==/UserScript== // URL 변경을 감지하는 함수 const detectUrlChange = () => { //console.log('URL이 변경되었습니다:', window.location.href); observer.disconnect(); // 기존 MutationObserver를 중지합니다. observer.observe(targetNode, config); // MutationObserver를 다시 연결합니다. }; // popstate 이벤트를 사용하여 URL 변경 감지 window.addEventListener('popstate', detectUrlChange); // pushState와 replaceState를 감지하기 위해 history API를 확장 const originalPushState = history.pushState; const originalReplaceState = history.replaceState; history.pushState = function(...args) { originalPushState.apply(this, args); detectUrlChange(); }; history.replaceState = function(...args) { originalReplaceState.apply(this, args); detectUrlChange(); }; // MutationObserver 설정 const targetNode = document.body; const config = { childList: true, subtree: true }; const observer = new MutationObserver(mutations => { // 나무위키 파워링크 삭제 (class : LBjkIL12, Emxr1Fw8) // 나무위키 상단 이미지 삭제 (class : W-W1lQk) // 나무위키 구글 광고 이미지 삭제 (attribute : data-google-query-id) document.querySelectorAll('[class*="LBjkIL12"], [class*="Emxr1Fw8"], [class*="W-W1lQk-"], [data-google-query-id]').forEach(element => { element.remove(); }); }); // 초기 로드 시 MutationObserver 연결 observer.observe(targetNode, config);