Disable Google AI Overview

Hides Google AI overviews. Loosely based on https://greasyfork.org/en/scripts/522574-hide-google-ai-overview.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Disable Google AI Overview
// @namespace    http://tampermonkey.net/
// @version      2025-12-20
// @description  Hides Google AI overviews. Loosely based on https://greasyfork.org/en/scripts/522574-hide-google-ai-overview.
// @author       jaredallard
// @match        *://www.google.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license      GPL-3.0
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let observer;
    let hidden = false;

    const hideDiv = () => {
        if (hidden) return;

        // As of 2025-12-20 only AI elements seem to have this data-al element, so we can key on it.
        document.querySelectorAll('div [data-al]').forEach(div => {
            div.style.display = 'none';
            hidden = true;
        });

        if (hidden) observer.disconnect();
    };

    // Optomistically try to hide it immediately.
    hideDiv();

    observer = new MutationObserver(hideDiv).observe(document.body, { childList: true, subtree: true });
})();