GitHub No Copilot

Hiding Silly Copilot in GitHub

2025-05-18 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         GitHub No Copilot
// @name:zh-CN   GitHub 隐藏 Copilot
// @description  Hiding Silly Copilot in GitHub
// @description:zh-CN 在 GitHub 上隐藏愚蠢的 Copilot
// @author       人民的勤务员 <[email protected]>
// @namespace    https://github.com/ChinaGodMan/UserScripts
// @supportURL   https://github.com/ChinaGodMan/UserScripts/issues
// @homepageURL  https://github.com/ChinaGodMan/UserScripts
// @license      MIT
// @match        https://github.com/*
// @icon        https://raw.githubusercontent.com/ChinaGodMan/UserScriptsHistory/main/scriptsIcon/github-commit-viewer.png
// @grant        none
// @compatible   chrome
// @compatible   firefox
// @compatible   edge
// @compatible   opera
// @compatible   safari
// @compatible   kiwi
// @compatible   qq
// @compatible   via
// @compatible   brave
// @version      2025.5.19.1
// @created      2025-05-19 02:19:24
// ==/UserScript==
/**
 * File: github-no-copilot.user.js
 * Project: UserScripts
 * File Created: 2025/05/19,Monday 02:19:25
 * Author: 人民的勤务员@ChinaGodMan ([email protected])
 * -----
 * Last Modified: 2025/05/19,Monday 03:27:16
 * Modified By: 人民的勤务员@ChinaGodMan ([email protected])
 * -----
 * License: MIT License
 * Copyright © 2024 - 2025 ChinaGodMan,Inc
 */

//! 删除顶部的 Copilot
const FUCK_HEAD_COPILOT = true

//! 删除文件右上角的 Copilot
const FUCK_FILE_COPILOT = true

//!https://github.com/dashboard 对话框
const style = document.createElement('style')
style.textContent = `
h2.my-2 {
        display: none !important;
    }
#dashboard > div > div.copilotPreview__container > copilot-dashboard-entrypoint {
    display: none !important;
}
`
document.head.appendChild(style)

function remove() {
    // 无需确认的元素
    const selectors = [
        //dashboard 同上css
        '.copilotPreview__container',

        //dashboard 同上css
        '.copilot-dashboard-entrypoint',

        // 侧边栏
        'a[data-analytics-event*="COPILOT"]'
    ]
    selectors.forEach(selector => {
        document.querySelectorAll(selector).forEach(element => element.remove())
    })

    // 可自定义开启或者关闭的元素
    const ButtonGroup = document.querySelector('#repos-sticky-header [class*=\'ButtonGroup\']')
    const CopilotChat = document.querySelector('.AppHeader-CopilotChat')
    if (FUCK_FILE_COPILOT && ButtonGroup) ButtonGroup.style.display = 'none'
    if (FUCK_HEAD_COPILOT && CopilotChat) CopilotChat.style.display = 'none'

}

new MutationObserver(remove).observe(document.body, {
    childList: true,
    subtree: true
})