Adds collapsible code blocks with clickable headers, footer controls, and a global toolbar toggle
See screenshots at the bottom
Adds clean collapse controls to code blocks (header toggle + footer bar) and a global toolbar control for collapsing/expanding all blocks. Ideal for long conversations with lots of code.
Long AI responses with multiple code blocks make conversations hard to navigate:
This script lets you collapse code blocks down to their header and expand them when needed.
| Action | Result |
|---|---|
| Click footer bar on a code block | Collapse that specific code block |
| Click code block header | Toggle collapse/expand for that block |
| Click toolbar “Collapse” | Collapse all code blocks |
| Click toolbar “Expand” | Expand all code blocks |
| Hold toolbar “Collapse” | Toggle persistent auto-collapse ON/OFF |
MutationObserver to only process newly added code blocks (no full-page rescans on every update).requestAnimationFrame during scroll/resize.Works immediately. The toolbar buttons appear next to the Submit button in the input area.
Enter or Space toggles/collapses depending on the focused control.