Google Search Result Domain Blocker

This script blocks domains from your google search results.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Google Search Result Domain Blocker
// @namespace    mailto:[email protected]
// @version      0.1
// @description  This script blocks domains from your google search results.
// @author       [email protected]
// @match        https://www.google.com/search*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //Load Filter
    let filter = {
        //'example.com' : true
    };

    //Cull Results
    let results = document.querySelectorAll('.rc');
    results.forEach((res)=>{
        //Get Domain
        let url = res.childNodes[0].childNodes[0].href;
        url = getDomain(url);

        if (filter[url]){
            res.parentNode.remove();
            console.log(`Filtered a result from: ${url}`);
        }
    });

    //Helper Functions
    function getDomain(url){
        url = url.slice( url.search('://')+3);
        url = url.slice(0, url.indexOf('/'));

        //Trim Subdomain
        if (url.split('.').length>2) {
            url = url.slice(url.indexOf('.')+1);
        }

        return url;
    }
})();