Last active
August 4, 2024 10:46
-
-
Save motebaya/aa3014022d1d05041ee2cd66d216d0b8 to your computer and use it in GitHub Desktop.
tampermonkey: just for remove modal/popup element from wp plugin: https://wordpress.org/plugins/chp-ads-block-detector/
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 remove ads detection ele | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-08-04 | |
// @description remove modal from plugin: https://wordpress.org/plugins/chp-ads-block-detector/ | |
// @author Lorem ipsum kolor si slamet | |
// @match *://<domain here>/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=<domain here> | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
"use strict"; | |
function rmEl() { | |
let footer = document.querySelector("footer"); | |
if (footer && footer.nextElementSibling) { | |
footer.nextElementSibling.remove(); | |
console.log("modal removed"); | |
} | |
document.querySelector("body").className = ""; | |
} | |
rmEl(); | |
let observer = new MutationObserver(function (mutations) { | |
mutations.forEach(function (mutation) { | |
if (mutation.addedNodes.length) { | |
rmEl(); | |
} | |
}); | |
}); | |
let config = { childList: true, subtree: true }; | |
observer.observe(document.body, config); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for some site, modal will be appear many times as example in here appear 13x, i do using mutation event to monitoring DOM change.