37

Using DuckDuckGo, it's possible to temporarily remove a specific site from search results by adding -site:example.com to the search query.

Is there a way to permanently block/blacklist/exclude undesired websites from search results? I didn't find anything in the DDG settings but maybe there is some Greasemonkey script or Firefox extension out there that could do the trick?

10
  • 7
    no, i'm asking for any kind of way to achieve this. exactly like this question (about a different search engine) which has 49 upvotes at the time of writing this. if there's something wrong with my question, then there's something wrong with that one as well.
    – foerno
    Aug 29, 2016 at 12:28
  • 3
    This question is okay, since there's a definite problem to be solved. A script or extension is just one way to do it. Obviously the Asker is open to any sort of solution.
    – ale
    Aug 29, 2016 at 12:45
  • 3
    Thanks for asking this. I need a way to keep w3schools out of my results Jan 18, 2021 at 19:31
  • 5
    @BradyDowling haha you should check the revision history for this question. :)
    – foerno
    Jan 19, 2021 at 23:39
  • 1
    @foerno it's beautiful and hideous at the same time 😂 Jan 20, 2021 at 16:44

2 Answers 2

11

ublacklist is an extension which lets you remove sites from search results.

Note that by default it works with Google, but you can enable DuckDuckGo and other search engines in the options.

1
6

With a standard URL rewrite/redirect pattern, you could use a Greasemonkey/Tampermonkey/generic userscript like:

// ==UserScript==
// @name        DuckDuckGo, Always add certain search parameters
// @match       *://*.duckduckgo.com/*
// @run-at      document-start
// @noframes
// @grant       none
// ==/UserScript==

//--- SET THIS NEXT VARIABLE TO TASTE.
//--- Seperate multiple site with the | key. i.e. -site:wikipedia.org|bbc.co.uk
var stickySrchTerm  = "-site:wikipedia.org";

var stckySrchEncdd  = encodeURIComponent (stickySrchTerm);
var oldUrlSearch    = location.search;

//--- Test that haven't already redirected.
if ( ! oldUrlSearch.includes (stckySrchEncdd) ) {
    //--- Our term must go in the `q=` portion of `location.search`.
    var srchParams  = oldUrlSearch.split ("&");
    for (var J = 0, L = srchParams.length;  J < L;  J++) {
        if (/^\??q=/.test (srchParams[J]) ) {
            srchParams[J] += "+" + stckySrchEncdd;
            break;
        }
    }
    var newUrlSearch    = srchParams.join ("&");
    var newURL          = location.protocol + "//"
                        + location.host
                        + location.pathname
                        + newUrlSearch
                        + location.hash
                        ;
    /*-- replace() puts the good page in the history instead of the
        bad page.
    */
    location.replace (newURL);
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.