Skip to content

Instantly share code, notes, and snippets.

@motebaya
Last active August 4, 2024 10:46
Show Gist options
  • Save motebaya/aa3014022d1d05041ee2cd66d216d0b8 to your computer and use it in GitHub Desktop.
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/
// ==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);
})();
@motebaya
Copy link
Author

motebaya commented Aug 4, 2024

for some site, modal will be appear many times as example in here appear 13x, i do using mutation event to monitoring DOM change.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment