Hide ChatGPT Header

隐藏 https://chatgpt.com/ 页面顶部的共享栏

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 or Violentmonkey 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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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         Hide ChatGPT Header
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  隐藏 https://chatgpt.com/ 页面顶部的共享栏
// @match        https://chatgpt.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 使用 MutationObserver 等待目标元素加载完成
    const observer = new MutationObserver(() => {
        const header = document.querySelector('.draggable.sticky.top-0.z-10.flex.min-h-[60px].items-center.justify-center.border-transparent.bg-token-main-surface-primary.pl-0.md\\:hidden');
        if (header) {
            header.style.display = 'none';
            observer.disconnect();  // 找到元素后停止观察
        }
    });

    // 开始观察整个页面的 DOM 变化
    observer.observe(document.body, { childList: true, subtree: true });
})();