ChatGPT Mail 去广告优化

隐藏 mail.chatgpt.org.uk 上的广告区域(header、google-auto-placed、grippy-host、aswift_3_host、aswift_4_host)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ChatGPT Mail 去广告优化
// @namespace    https://mail.chatgpt.org.uk/
// @version      1.0.0
// @description  隐藏 mail.chatgpt.org.uk 上的广告区域(header、google-auto-placed、grippy-host、aswift_3_host、aswift_4_host)
// @author       h7ml<[email protected]>
// @match        https://mail.chatgpt.org.uk/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 所有需要隐藏的元素选择器
    const selectors = [
        'div.header',
        'div.google-auto-placed',
        'div.grippy-host',
        '#aswift_3_host',
        '#aswift_4_host'
    ];

    // 隐藏函数
    function hideAds() {
        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                el.style.display = 'none';
                el.style.visibility = 'hidden';
                el.style.height = '0';
                el.style.margin = '0';
                el.style.padding = '0';
            });
        });
    }

    // 初次执行
    hideAds();

    // 监听页面变化(广告异步加载时也能屏蔽)
    const observer = new MutationObserver(() => hideAds());
    observer.observe(document.body, { childList: true, subtree: true });
})();