Google Search: Remove AI Results

Appends Google Search queries with a string of phrases designed to exclude webpages that use AI, without you manually having to append arguments. If you want to stop these arguments getting added, add an underscore as the last character of your search query.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Google Search: Remove AI Results
// @namespace    https://sinisterpixel.tv
// @version      1.1
// @description  Appends Google Search queries with a string of phrases designed to exclude webpages that use AI, without you manually having to append arguments. If you want to stop these arguments getting added, add an underscore as the last character of your search query.
// @author       Sinister Pixel
// @match        https://www.google.com/search*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Phrases to append to the search query
    const appendPhrases = "-\"stable diffusion\" -\"ai\" -\"midjourney\" -\"open art\" -\"prompt hunt\"";
    const flagParam = 'modified'; // Flag to prevent infinite redirection

    // Get the current URL parameters
    const urlParams = new URLSearchParams(window.location.search);

    // Check if the script has already modified the query
    if (urlParams.has(flagParam)) {
        return; // Exit if already modified
    }

    const query = urlParams.get('q');

    // Check if the query exists, does not end with an underscore, and does not already include the appended phrases
    if (query && query.slice(-1) !== "_" && !query.includes(appendPhrases)) {
        // Append the phrases
        const modifiedQuery = `${query} ${appendPhrases}`;

        // Update the search query parameter
        urlParams.set('q', modifiedQuery);

        // Add the flag parameter to prevent infinite redirection
        urlParams.set(flagParam, 'true');

        // Redirect to the modified URL
        const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
        window.location.replace(newUrl);
    }
})();