Created
October 9, 2026 06:16
-
-
Save unitycoder/4ff03865aefd81fdcd887febfa2686dd to your computer and use it in GitHub Desktop.
[GreaseMonkey] Fix Github Gist Search (search my own gists easily)
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 Search My Gists | |
| // @namespace https://unitycoder.com/ | |
| // @version 09.10.2026 | |
| // @description Automatically add the logged-in username to Gist searches. | |
| // @match https://gist.github.com/* | |
| // @run-at document-idle | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| function updateSearch() { | |
| const avatar = document.querySelector('img.avatar-user[alt^="@"]'); | |
| if (!avatar) return; | |
| const username = avatar.getAttribute('alt').slice(1); | |
| if (!/^[a-zA-Z0-9-]+$/.test(username)) return; | |
| const search = document.querySelector('form[action*="/search"] input[name="q"], input[name="q"][type="search"]'); | |
| if (!search || search.dataset.gistUserAdded) return; | |
| const qualifier = `user:${username}`; | |
| const current = search.value.trim()+" "; | |
| if (!/\buser:\S+/i.test(current)) { | |
| search.value = current ? `${qualifier} ${current}` : `${qualifier}`; | |
| } | |
| search.dataset.gistUserAdded = 'true'; | |
| } | |
| updateSearch(); | |
| const observer = new MutationObserver(updateSearch); | |
| observer.observe(document.body, { childList: true, subtree: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment