Created
October 29, 2025 08:00
-
-
Save bluwy/803c6d4f33d120ca5f213fd7f5fde9a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Refined GitHub Copilot UI | |
| // @license MIT | |
| // @version 0.0.1 | |
| // @description Remove clutter in the GitHub Copilot UI | |
| // @author Bjorn Lu | |
| // @match https://github.com/** | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com | |
| // @grant none | |
| // ==/UserScript== | |
| ;(function () { | |
| 'use strict' | |
| run() | |
| // listen to github page loaded event | |
| document.addEventListener('pjax:end', () => run()) | |
| document.addEventListener('turbo:render', () => run()) | |
| // Also check for changes for the first 3 seconds with React-based UI | |
| const debouncedRun = debounce(run, 200) | |
| const observer = new MutationObserver(() => debouncedRun()) | |
| observer.observe(document.body, { childList: true, subtree: true }) | |
| setTimeout(() => observer.disconnect(), 3000) | |
| })() | |
| function run() { | |
| if (location.pathname.startsWith('/copilot')) { | |
| // Remove useless sidebar links | |
| removeElement('li', 'a[href="/copilot/agents"]') | |
| removeElement('li', 'a[href="/copilot/spaces"]') | |
| removeElement('li', 'a[href="/spark"]') | |
| // Remove useless "Agent sessions" sidebar section | |
| removeElement( | |
| 'div[class^="SidebarNavigation-module__sectionContainer"]', | |
| 'a[href^="/copilot/tasks"]' | |
| ) | |
| // Remove useless command starters | |
| removeElement('div[class^="NewConversation-module__commandStarters"]') | |
| // Remove useless "Recent agent sessions" section AGAIN | |
| removeElement('div[class^="NewConversation-module__agentListContainer"]') | |
| } | |
| } | |
| /** | |
| * @param {string} selector | |
| * @param {string} [containsSelector] | |
| */ | |
| function removeElement(selector, containsSelector) { | |
| const query = containsSelector | |
| ? `${selector}:has(${containsSelector})` | |
| : selector | |
| const el = document.querySelector(query) | |
| if (el) { | |
| el.remove() | |
| } else { | |
| console.warn(`Element not found: ${query}`) | |
| } | |
| } | |
| function debounce(fn, wait) { | |
| let timeout | |
| return function (...args) { | |
| clearTimeout(timeout) | |
| timeout = setTimeout(() => fn.apply(this, args), wait) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment