Github hide banner

You can toggle the github banner.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Github hide banner
// @namespace    http://tampermonkey.net/
// @version      0.11
// @description  You can toggle the github banner.
// @description:zh-CN   去除github代码页顶部的标题栏
// @author       Movelocity
// @license      MIT License
// @match        https://github.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  function modify_page(){
    // get target elements
    let banner = document.querySelector('.Box-sc-g0xbh4-0.ePiodO');
    let code_container = document.querySelector('.Box-sc-g0xbh4-0.jCjMRf');

    // Create a new button element
    let toggleButton = document.createElement('button');
    toggleButton.textContent = 'Toggle';

    // Add a click event listener to the button
    toggleButton.addEventListener('click', function() {
    if (banner.style.display === 'none') {
      banner.style.display = '';
      code_container.style.marginTop = '46px';
      console.log("show");
    } else {
      banner.style.display = 'none';
      code_container.style.marginTop = '0';
      console.log("hide");
    }
    });
    // Insert toggle button
    document.querySelector('.Header-item.d-md-none').after(toggleButton);
  }
	window.setTimeout(modify_page, 3000);
})(); // execute the function we just defined (func)()