Last active
April 17, 2019 16:54
-
-
Save PtaxLaine/9611ca300dd391b94e20701fd38d655a to your computer and use it in GitHub Desktop.
search blocklist
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
// ==UserScript== | |
// @name SEARCH Blocklist | |
// @version 0.1 | |
// @match https://duckduckgo.com/?* | |
// @match https://www.google.com/search?* | |
// @match https://google.com/search?* | |
// @match https://www.google.ru/search?* | |
// @match https://google.ru/search?* | |
// @grant none | |
// ==/UserScript== | |
(()=>{ | |
var blocklist = ['qaru.site', 'askvoprosy.com', 'kompsekret.ru']; | |
function duckduckgo(){ | |
for(var domain of blocklist){ | |
var query = document.querySelectorAll(`[data-domain='${domain}']`); | |
for(var i = 0; i < query.length; ++i){ | |
var el = query[i]; | |
el.remove(); | |
} | |
} | |
} | |
function google(){ | |
var query = document.querySelectorAll(`div.g`); | |
for(var domain of blocklist){ | |
for(var i = 0; i < query.length; ++i){ | |
var g = query[i] | |
var a = g.querySelector(`a`); | |
if(a){ | |
if(domain == a.hostname){ | |
g.remove(); | |
} | |
} | |
} | |
} | |
} | |
function initilaze() { | |
if (['complete', 'interactive'].indexOf(document.readyState) >= 0) { | |
if(document.location.hostname.indexOf('duckduckgo') >= 0){ | |
duckduckgo(); | |
}else if(document.location.hostname.indexOf('google') >= 0){ | |
google(); | |
} | |
setTimeout(initilaze, 100); | |
} else { | |
window.addEventListener("DOMContentLoaded", initilaze); | |
} | |
} | |
initilaze(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment