Google Search Results Filter

Hides specific Google search results based on href values. Motivation: I keep wasting my time opening reddit from search results and realizing that I don't have an access there

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Google Search Results Filter
// @namespace    https://greasyfork.org/en/users/1413127-tumoxep
// @version      1.1
// @description  Hides specific Google search results based on href values. Motivation: I keep wasting my time opening reddit from search results and realizing that I don't have an access there
// @license      WTFPL
// @match        https://www.google.com/search*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // List of keywords or URL substrings to hide
    const blacklist = [
        "air.io",
    ];

    // Function to hide unwanted search results
    function filterResults() {
        // Select all results inside the #search element
        const results = document.querySelectorAll(`[data-hveid]:not([data-hveid=""])[jsaction]:not([jsaction=""])[data-hveid]:not([data-hveid=""])[data-ved]:not([data-ved=""])`); // Adjust if necessary based on class structure

        results.forEach((result) => {
            try {
                // Get the link nested 9 levels deep
                const link = result.querySelector("a");
                if (link && blacklist.some(keyword => link.href.includes(keyword))) {
                    // Hide the result if it matches the blacklist
                    result.style.display = 'none';
                }
            } catch (e) {
                console.error("Error processing result:", e);
            }
        });
    }

    // Run the filter when the page loads or updates
    const observer = new MutationObserver(filterResults);
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial filter run
    filterResults();
})();