Skip to content

Instantly share code, notes, and snippets.

@remram44
Last active December 1, 2023 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remram44/407be77a5649e2c816064a7ac0132ac0 to your computer and use it in GitHub Desktop.
Save remram44/407be77a5649e2c816064a7ac0132ac0 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Block domains from duckduckgo
// @namespace http://tampermonkey.net/
// @version 0.1
// @description A userscript to remove search results from specific domains
// @author Remi Rampin <remirampin@gmail.com>
// @match https://duckduckgo.com/*
// ==/UserScript==
// https://gist.github.com/remram44/407be77a5649e2c816064a7ac0132ac0
(function() {
'use strict';
let domains = [
'9to5answer.com',
'awesomeopensource.com',
'clariontech.com',
'educba.com',
'geeksforgeeks.org',
'hevodata.com',
'libhunt.com',
'stackshare.io',
'stevehacks.com',
'trustradius.com',
'w3schools.blog',
'w3schools.com',
'wikidiff.com',
'kubernetesquestions.com',
];
function filterLinks() {
if(filterLinks.active) return;
filterLinks.active = true;
let ls = document.querySelectorAll('ol.react-results--main > li');
ls.forEach((l) => {
for(let a of l.querySelectorAll('a')) {
for(let d of domains) {
if(a.href && a.href.indexOf(d) !== -1) {
l.remove();
return;
}
}
}
});
filterLinks.active = false;
}
filterLinks.active = false;
function start() {
let links = document.querySelector('.react-results--main');
if(links) {
links.addEventListener('DOMSubtreeModified', filterLinks);
filterLinks();
} else {
setTimeout(start, 500);
}
}
start();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment