Github hide banner

You can toggle the github banner.

  1. // ==UserScript==
  2. // @name Github hide banner
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.11
  5. // @description You can toggle the github banner.
  6. // @description:zh-CN 去除github代码页顶部的标题栏
  7. // @author Movelocity
  8. // @license MIT License
  9. // @match https://github.com/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. function modify_page(){
  17. // get target elements
  18. let banner = document.querySelector('.Box-sc-g0xbh4-0.ePiodO');
  19. let code_container = document.querySelector('.Box-sc-g0xbh4-0.jCjMRf');
  20.  
  21. // Create a new button element
  22. let toggleButton = document.createElement('button');
  23. toggleButton.textContent = 'Toggle';
  24.  
  25. // Add a click event listener to the button
  26. toggleButton.addEventListener('click', function() {
  27. if (banner.style.display === 'none') {
  28. banner.style.display = '';
  29. code_container.style.marginTop = '46px';
  30. console.log("show");
  31. } else {
  32. banner.style.display = 'none';
  33. code_container.style.marginTop = '0';
  34. console.log("hide");
  35. }
  36. });
  37. // Insert toggle button
  38. document.querySelector('.Header-item.d-md-none').after(toggleButton);
  39. }
  40. window.setTimeout(modify_page, 3000);
  41. })(); // execute the function we just defined (func)()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址