Hide StackOverflow in Google Search

hide stackoverflow. research independently.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Hide StackOverflow in Google Search
// @namespace    http://tampermonkey.net/
// @version      2024-12-23
// @description  hide stackoverflow. research independently.
// @author       You
// @match        https://www.google.com/**
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';
// the search area
    const area = document.querySelector("div#search")
    // the results
    const first_result = area.childNodes[0].childNodes[1].childNodes[0]
    const other_results = area.childNodes[0].childNodes[1].childNodes[2].childNodes
    let results = [first_result]
    for(let i=0; i<other_results.length; i++) {
        results.push(other_results[i])
    }
    for(let i=0; i<results.length; i++) {
        let spans = results[i].querySelectorAll("span + div > div >span")
        for(let j=0; j<spans.length; j++) {
            let span=spans[j];
            if (span.textContent === "Stack Overflow"|| span.textContent==="Ask Ubuntu" || span.textContent==="Super User" ) {
                console.log(results[i]);
                results[i].style.display = "none";
                break;
            }
        }
    }
})();