隐藏github blob页面的header

Hides the header section of a specific GitHub page.

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

(I already have a user script manager, let me install it!)

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         隐藏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);
})();