Skip to content

Instantly share code, notes, and snippets.

@mistificator
Last active April 30, 2018 18:26
Show Gist options
  • Save mistificator/2e4d169c9c7368961d640da8c9042306 to your computer and use it in GitHub Desktop.
Save mistificator/2e4d169c9c7368961d640da8c9042306 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Yandex.Direct Killer
// @namespace https://gist.github.com/mistificator
// @run-at document-end
// @include http://lenta.ru/*
// @include https://lenta.ru/*
// @version 0.3
// @description Kills Yandex Direct on Lenta.ru.
// @author Mist Poryvaev
// @grant none
// ==/UserScript==
var timerId = setInterval(function()
{
var links = (document.getElementsByTagName("A"));
var ads_count = 0;
for (var i = 0; i < links.length; i++)
{
/*
if (links[i].getAttribute("href").indexOf("palacesquare.rambler.ru") != -1) // every link sends us to ad
{
console.log("emulate ad click");
links[i].setAttribute("target", "_blank");
links[i].click();
console.log("every link sends us to ad, reload page from server");
window.location.reload(true);
return;
}
*/
if (links[i].textContent.indexOf("Янд") != -1 && links[i].textContent.indexOf(".Ди") != -1) // you are fucking crazy bastards
{
var ad = links[i].parentNode.parentNode.parentNode;
if (ad.tagName.toLowerCase() != "span" || ad.tagName.toLowerCase() != "div")
{
ad = ad.parentNode;
}
// console.log(ad);
ad.remove(); // bye bye
ads_count++;
}
}
if (ads_count > 0)
{
console.log(ads_count + " ads removed");
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment