Skip to content

Instantly share code, notes, and snippets.

@ailinykh
Last active June 13, 2022 13:48
Show Gist options
  • Save ailinykh/18f95f08ac8cf3111e79c9b204a84cc6 to your computer and use it in GitHub Desktop.
Save ailinykh/18f95f08ac8cf3111e79c9b204a84cc6 to your computer and use it in GitHub Desktop.
Yandex Direct Removing
// ==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"));
// google
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 });
})();
@ip75
Copy link

ip75 commented Jun 13, 2022

do not work

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