Disable Google AI Overview

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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 });
})();