Skip to content

Instantly share code, notes, and snippets.

@adinan-cenci
Last active June 23, 2019 10:59
Show Gist options
  • Save adinan-cenci/e545c87c0ca6bbb51267d41881847774 to your computer and use it in GitHub Desktop.
Save adinan-cenci/e545c87c0ca6bbb51267d41881847774 to your computer and use it in GitHub Desktop.
I hate Pinterest, so to be free from it I wrote this code to censure it from google search results with the help of "Injector" chrome extension
function getRidOfSearchResults()
{
for (let c of document.querySelectorAll('cite')){
if (! /pinterest\./.test(c.innerText)) {
continue;
}
var wrapper = getParentWithClass(c, 'g');
wrapper.style.opacity = 0.1;
}
}
function getRidOfImages()
{
for (let span of document.querySelectorAll('.nJGrxf span')){
if (! /pinterest\./.test(span.innerText)) {
continue;
}
var wrapper = getParentWithClass(span, 'rg_bx');
wrapper.style.opacity = 0.1;
}
}
function getParentWithClass(element, className)
{
var wrapper = element.parentNode;
while (! wrapper.classList.contains(className)) {
wrapper = wrapper.parentNode;
}
return wrapper;
}
/* to detect when more images are loaded */
var bodyOffsetHeight = 0;
function checkHeight()
{
if (document.body.offsetHeight > bodyOffsetHeight) {
bodyOffsetHeight = document.body.offsetHeight;
getRidOfImages();
}
}
getRidOfSearchResults();
getRidOfImages();
setInterval(checkHeight, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment