GitHub No Copilot

Hiding Silly Copilot in GitHub

目前為 2025-05-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name GitHub No Copilot
  3. // @name:zh-CN GitHub 隐藏 Copilot
  4. // @description Hiding Silly Copilot in GitHub
  5. // @description:zh-CN 在 GitHub 上隐藏愚蠢的 Copilot
  6. // @author 人民的勤务员 <china.qinwuyuan@gmail.com>
  7. // @namespace https://github.com/ChinaGodMan/UserScripts
  8. // @supportURL https://github.com/ChinaGodMan/UserScripts/issues
  9. // @homepageURL https://github.com/ChinaGodMan/UserScripts
  10. // @license MIT
  11. // @match https://github.com/*
  12. // @icon https://raw.githubusercontent.com/ChinaGodMan/UserScriptsHistory/main/scriptsIcon/github-commit-viewer.png
  13. // @grant none
  14. // @compatible chrome
  15. // @compatible firefox
  16. // @compatible edge
  17. // @compatible opera
  18. // @compatible safari
  19. // @compatible kiwi
  20. // @compatible qq
  21. // @compatible via
  22. // @compatible brave
  23. // @version 2025.5.19.1
  24. // @created 2025-05-19 02:19:24
  25. // ==/UserScript==
  26. /**
  27. * File: github-no-copilot.user.js
  28. * Project: UserScripts
  29. * File Created: 2025/05/19,Monday 02:19:25
  30. * Author: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com)
  31. * -----
  32. * Last Modified: 2025/05/19,Monday 03:27:16
  33. * Modified By: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com)
  34. * -----
  35. * License: MIT License
  36. * Copyright © 2024 - 2025 ChinaGodMan,Inc
  37. */
  38.  
  39. //! 删除顶部的 Copilot
  40. const FUCK_HEAD_COPILOT = true
  41.  
  42. //! 删除文件右上角的 Copilot
  43. const FUCK_FILE_COPILOT = true
  44.  
  45. //!https://github.com/dashboard 对话框
  46. const style = document.createElement('style')
  47. style.textContent = `
  48. h2.my-2 {
  49. display: none !important;
  50. }
  51. #dashboard > div > div.copilotPreview__container > copilot-dashboard-entrypoint {
  52. display: none !important;
  53. }
  54. `
  55. document.head.appendChild(style)
  56.  
  57. function remove() {
  58. // 无需确认的元素
  59. const selectors = [
  60. //dashboard 同上css
  61. '.copilotPreview__container',
  62.  
  63. //dashboard 同上css
  64. '.copilot-dashboard-entrypoint',
  65.  
  66. // 侧边栏
  67. 'a[data-analytics-event*="COPILOT"]'
  68. ]
  69. selectors.forEach(selector => {
  70. document.querySelectorAll(selector).forEach(element => element.remove())
  71. })
  72.  
  73. // 可自定义开启或者关闭的元素
  74. const ButtonGroup = document.querySelector('#repos-sticky-header [class*=\'ButtonGroup\']')
  75. const CopilotChat = document.querySelector('.AppHeader-CopilotChat')
  76. if (FUCK_FILE_COPILOT && ButtonGroup) ButtonGroup.style.display = 'none'
  77. if (FUCK_HEAD_COPILOT && CopilotChat) CopilotChat.style.display = 'none'
  78.  
  79. }
  80.  
  81. new MutationObserver(remove).observe(document.body, {
  82. childList: true,
  83. subtree: true
  84. })