Skip to content

Instantly share code, notes, and snippets.

@AtoraSuunva
Created June 22, 2020 19:05
Show Gist options
  • Save AtoraSuunva/a19c45e5414ebb12e5f7a6a9287a5a45 to your computer and use it in GitHub Desktop.
Save AtoraSuunva/a19c45e5414ebb12e5f7a6a9287a5a45 to your computer and use it in GitHub Desktop.
Removes Pinterest and it's 1000 domains from Google search (By shoving them into a <details>)
// ==UserScript==
// @name Google Pinterest Remover
// @description Removes Pinterest and it's 1000 domains from Google search (By shoving them into a <details>)
// @version 2
// @include http*://www.google.*/search*
// @grant none
// ==/UserScript==
const res = document.getElementById('res')
const hidden = document.createElement('details')
const summary = document.createElement('summary')
const siteReg = /(?:https?:\/\/)?(?:www\.)?(.*?)\./
const blacklist = ['pinterest']
const isBlacklisted = site => {
const match = siteReg.exec(site)
return match && blacklist.includes(match[1].toLowerCase())
}
hidden.appendChild(summary)
for (let a of res.querySelectorAll('.g')) {
if (a.id) continue
const cite = a.getElementsByTagName('cite')[0]
const site = cite ? cite.innerText : ''
if (site && isBlacklisted(site)) {
hidden.appendChild(a.cloneNode(true))
a.parentElement.removeChild(a)
}
}
if (hidden.children.length > 1) {
summary.innerText = `Hidden Pinterest Results (${hidden.children.length})`
hidden.style.paddingBottom = '30px'
hidden.style.color = '#eee'
res.appendChild(hidden)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment