Google Search Result Clean

Remove "People also ask", "Featured Snippets", "Video", "Image", "Searches related to ...", "Twitter", etc. Remove naive websites.

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         Google Search Result Clean
// @namespace    http://tampermonkey.net/
// @license MIT
// @version      0.12
// @description  Remove "People also ask", "Featured Snippets", "Video", "Image", "Searches related to ...", "Twitter", etc. Remove naive websites.
// @homepage     https://greasyfork.org/zh-CN/scripts/393699
// @author       Saisai Lu
// @match        https://*.google.com/search*
// ==/UserScript==

(function() {
    'use strict';

    // Remove naive and annoying websites.
    // Comment this out, use uBlacklist instead
    /*
    let hostsToBlock = ['www.w3schools.com', 'www.asciitable.com', 'www.dba-oracle.com', 'www.geeksforgeeks.org', 'www.tutorialspoint.com'];
    document.querySelectorAll('.g').forEach(result => {
        let a = result.querySelector('a');
        if (a && hostsToBlock.includes(a.host)) {
            result.remove();
        }
    });
    */

    // remove 'Featured Snippets'
    let firstLine = document.querySelector('.g')
    firstLine.querySelectorAll('a').forEach(link => {
        if (link.textContent == 'About Featured Snippets') {
            firstLine.remove();
        }
    });

    let resultLines = document.querySelectorAll('div#search>div>div>div');

    resultLines.forEach(resultLine => {
        resultLine.querySelectorAll('span').forEach(span => {
            //console.log(span.textContent);
            if (span.textContent == 'People also ask') {
                resultLine.remove();
            }
        });

        resultLine.querySelectorAll('a').forEach(span => {
            //console.log(span.textContent);
            if (span.textContent == 'About featured snippets') {
                resultLine.remove();
            }
        });

        resultLine.querySelectorAll('h3').forEach(span => {
            //console.log(span.textContent);
            if (span.textContent == 'Videos') {
                resultLine.remove();
            }
        });

        resultLine.querySelectorAll('span').forEach(span => {
            if (span.textContent == 'View on Twitter') {
                resultLine.remove();
            }
        });

        resultLine.querySelectorAll('img').forEach(span => {
            resultLine.remove();
        });

    });

    // remove "Searches related to ..."
    let relatedSearches = document.getElementById('bres');
    if (relatedSearches != null) relatedSearches.remove();
})();