Greasy Fork

나무위키 광고 삭제

데스크탑 View(Edge)는 확인되었으나, 모바일 View(Safari) 상에서는 갱신에 문제가 있는 듯 합니다.

目前为 2025-03-26 提交的版本。查看 最新版本

// ==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/*
// @grant       none
// @version     1.11
// @author      Xlbatross
// @run-at      document-end
// @description 데스크탑 View(Edge)는 확인되었으나, 모바일 View(Safari) 상에서는 갱신에 문제가 있는 듯 합니다.
// ==/UserScript==

// MutationObserver 설정
const targetNode = this.document.body;
const config = { childList: true, subtree: true };

const observer = new MutationObserver(mutations => {
    // 나무위키 파워링크 삭제 (class : LBjkIL12, Emxr1Fw8)
    // 나무위키 상단 이미지 삭제 (class : W-W1lQk)
    // 나무위키 구글 광고 이미지 삭제 (attribute : data-google-query-id)
    this.document.querySelectorAll('[class*="LBjkIL12"], [class*="Emxr1Fw8"], [class*="W-W1lQk-"], [data-google-query-id]').forEach(element => {
        element.remove();
    });
});

// 초기 로드 시 MutationObserver 연결
observer.observe(targetNode, config);

// 모바일에서 링크 클릭으로 갱신은 되게 하는 코드.
//this.document.addEventListener('click', function(event) {
//    const anchor = event.target.closest('a[href]');
//    if (anchor) {
//      if (anchor.href != "#")
//        location.href = anchor.href;
//    }
//});