Created
July 1, 2026 06:10
-
-
Save briandeheus/a4090389f1b6beb22fbd47ffc6bcb0d6 to your computer and use it in GitHub Desktop.
Claude Code Auto-Expander
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
| (() => { | |
| if (window.stopExpand) { console.log("[expand] already running — call stopExpand() first"); return; } | |
| const SELECTOR = '[aria-expanded="false"]'; | |
| const MENUISH = '[aria-haspopup],[role="combobox"],[role="menu"],[role="menuitem"],[role="listbox"],[role="dialog"],nav,header'; | |
| const root = () => document.querySelector('[data-testid="conversation"], [data-testid="chat-messages"], main [role="log"], main') || document.body; | |
| const isChip = (el) => !el.closest(MENUISH) && !el.matches(MENUISH) && root().contains(el); | |
| const seen = new WeakSet(); | |
| let count = 0; | |
| const sweep = () => { | |
| for (const el of root().querySelectorAll(SELECTOR)) { | |
| if (seen.has(el) || !isChip(el)) continue; | |
| seen.add(el); | |
| try { el.click(); count++; } catch {} | |
| } | |
| }; | |
| let queued = false; | |
| const schedule = () => { if (queued) return; queued = true; requestAnimationFrame(() => { queued = false; sweep(); }); }; | |
| sweep(); | |
| const obs = new MutationObserver(schedule); | |
| obs.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["aria-expanded"] }); | |
| window.stopExpand = () => { obs.disconnect(); delete window.stopExpand; console.log(`[expand] stopped (${count} expanded)`); }; | |
| console.log(`[expand] running (conversation-scoped) — ${count} expanded so far. Call stopExpand() to stop.`); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment