Last active
June 13, 2022 13:48
-
-
Save ailinykh/18f95f08ac8cf3111e79c9b204a84cc6 to your computer and use it in GitHub Desktop.
Yandex Direct Removing
This file contains 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 Yandex Direct Remover | |
// @namespace https://gist.github.com | |
// @version 0.3.9 | |
// @description Remove yandex direct ad from all pages! | |
// @author Anthony Ilinykh | |
// @match *://*/* | |
// @grant none | |
// @updateURL https://gist.github.com/ailinykh/18f95f08ac8cf3111e79c9b204a84cc6/raw/no-direct.user.js | |
// ==/UserScript== | |
(function() { | |
const target = document.getElementsByTagName('body')[0]; | |
let timeoutID; | |
// Remove all yatags | |
const removeYaTags = () => { | |
let yatags = Array.from(document.querySelectorAll("yatag")); | |
// get only root nodes | |
yatags = yatags.filter(t => t.parentNode.nodeName.toLowerCase() !== 'yatag'); | |
// yandex music top banner | |
yatags.push(document.querySelector(".page-root_no-player .d-overhead")); | |
// vkontakte | |
yatags.push(document.querySelector("#ads_left")); | |
yatags.push(document.querySelector(".adsbygoogle")); | |
// meduza | |
yatags.push(document.querySelector(".DFPBanner-root")); | |
yatags.push(document.querySelector("#div-gpt-ad")); | |
// now get rid of them! | |
yatags.forEach(y => { | |
if(y && y.parentNode) { | |
y.parentNode.removeChild(y); | |
} | |
}); | |
}; | |
// create an observer instance | |
const observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
// set timeout to prevent multiple calls | |
if (timeoutID) { | |
clearTimeout(timeoutID); | |
} | |
timeoutID = setTimeout(removeYaTags, 300); | |
}); | |
}); | |
// pass in the target node, as well as the observer options | |
observer.observe(target, { childList: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
do not work