隐藏github blob页面的header

Hides the header section of a specific GitHub page.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         隐藏github blob页面的header
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Hides the header section of a specific GitHub page.
// @match        https://github.com/*/blob/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 创建样式元素
    const style = document.createElement('style');
    style.textContent = `
        .AppHeader {
            display: none !important;
        }
    `;
    document.head.appendChild(style);

    // 监听 DOM 变化,处理动态加载的元素
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            const appHeaders = document.getElementsByClassName('AppHeader');
            for (let header of appHeaders) {
                header.style.display = 'none';
            }
        });
    });

    // 配置观察选项
    const config = {
        childList: true,
        subtree: true
    };

    // 开始观察文档变化
    observer.observe(document.body, config);
})();