Github hide banner

You can toggle the github banner.

目前為 2023-05-27 提交的版本,檢視 最新版本

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

QingJ © 2025

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