-
-
Save HexagonWin/db47a2adeab0ac1cf297a9a65b307cc9 to your computer and use it in GitHub Desktop.
namupower.user.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name NamuPower | |
// @namespace Violentmonkey Scripts | |
// @match https://namu.wiki/w/* | |
// @grant none | |
// @version 1.4 | |
// @author - | |
// @run-at document-start | |
// ==/UserScript== | |
let adClass = ''; | |
function depth(e){ | |
let i = 0; | |
while(e.id !== 'app' && e) e = e.parentElement, i++; | |
return i; | |
} | |
new MutationObserver(async (a, b) => { | |
a.map(e1 => { | |
if (e1.addedNodes.length) { | |
Array.from(e1.addedNodes).map((e) => { | |
const parent = e.parentElement; | |
if(!parent) return; | |
if(parent.tagName === 'DIV' && parent.className === '' && parent.parentElement.tagName === 'DIV') { | |
const allElement = Array.from(parent.parentElement.querySelectorAll('span')); | |
if(allElement.filter(e=>window.getComputedStyle(e,false).backgroundImage.startsWith('url("data:image/png;base64,')).length >= 2 || allElement.filter(e=>e.innerText==='파워링크').length !== 0 || allElement.filter(e=>e.innerText==='광고').length !== 0){ | |
parent.parentElement.remove(); | |
} | |
const imgElement = Array.from(parent.parentElement.querySelectorAll('img')); | |
if(imgElement.filter(e=>e.src === 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iMTUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PC9zdmc+').length){ | |
setTimeout(()=>parent.parentElement.remove(), 10); | |
} | |
} | |
// for mobile | |
else if(e.tagName === 'SPAN' && parent.tagName === 'SPAN' &&parent.parentElement.tagName === 'DIV') { | |
if(!e.querySelectorAll('img')) return; | |
if(!Array.from(e.querySelectorAll('img')).filter(e=>e.style.color!=='').length){ | |
return; | |
} | |
// hide leftovers | |
const p = parent.parentElement.parentElement; | |
p.parentElement.style['min-height'] = '0'; | |
p.parentElement.style['height'] = '0'; | |
adClass = p.parentElement.className; | |
parent.parentElement.parentElement.remove(); | |
return; | |
} | |
}); | |
} | |
}); | |
}).observe(document, { subtree: true, childList: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment