Last active
June 23, 2019 10:59
-
-
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
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
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