Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Last active March 23, 2024 21:10
Show Gist options
  • Save ddrscott/7651a0d76655807095e3746c038a4651 to your computer and use it in GitHub Desktop.
Save ddrscott/7651a0d76655807095e3746c038a4651 to your computer and use it in GitHub Desktop.
TamperMonkey - Remove Ads elements after Ajax stuff loads
// ==UserScript==
// @name Remove Ads
// @namespace https://ddrscott.github.io/remove_ads
// @version 0.5
// @description Removes elements that are thought to be ads.
// @author Scott Pierce
// @match https://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const selectors = [
"[data-ad-client]",
".adsbygoogle",
"[id^=google_ads]",
"[data-google-query-id]",
"#cookie-law-info-bar",
".adsbyvli",
"[id^=invisible_high_impact]",
".top-ads-container",
".bottom-ads-container",
".mv-video-target",
".avisdiv",
"[class^=adthrive]",
];
const send = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function() {
this.addEventListener('load', function() {
window.setTimeout(() => {
document.querySelectorAll(selectors.join(", ")).forEach((e) => e.remove());
// https://animixplay.to
document.querySelectorAll('.xclose').forEach((e) => e.parentElement.remove());
}, 0);
})
return send.apply(this, arguments)
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment