Removing LinkedIn from DuckDuckGo searches in Firefox

I am using Firefox as my browser, and DuckDuckGo as a search engine.

I don’t want LinkedIn results in my searches.

On a case by case basis, I can added -site:linkedin.com to the search, but I don’t want to do that each time.

There doesn’t appear to be a config option within Firefox. I had a look in about:config, without luck.

I installed the TamperMonkey extension/add-on, and added a simple script, based on this StackOverflow post:

// ==UserScript==
// @name        DuckDuckGo, Always add certain search parameters
// @namespace    No_idea
// @version      0.1
// @description  Remove LinkedIn from DDG search results
// @author       You
// @match       *://*.duckduckgo.com/*
// @grant        none
// @run-at      document-start
// @noframes
// ==/UserScript==

(function() {
    'use strict';

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

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);
}

})();

An alternative approach

A kind fedizen, David, said:

as an alternative I use a userscript which hides domains from results (as opposed to excluding domains from the search). Works very well