Google AI Studio | Toggle Code Blocks

Toggle all code blocks open/closed in Google AI Studio with lazy loading support.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

Autor
piknockyou
Denne inštalácií
1
Celkový počet inštalácií
2
Hodnotenie
0 0 0
Verzia
1.4
Vytvorené
21.12.2025
Aktualizované
22.12.2025
Veľkosť
10,2 KB
Licencia
AGPL-3.0
Spustiť na

Google AI Studio | Toggle Code Blocks

Introduces the ability to manage code block visibility in Google AI Studio. Adds a toolbar button to instantly collapse or expand all code snippets for a cleaner workspace.

Features

  • Smart Initial Action: The first click always collapses all code blocks to immediately de-clutter the view.
  • Persistent Mode: Your preference (Collapse or Expand) is saved to local storage and persists across page reloads and different chats.
  • Lazy Loading Support: Automatically manages code blocks that appear as you scroll up or as the AI generates them in real-time.
  • Color-Coded Feedback:
    • Gray Icon: Inactive (Click to activate Collapse Mode).
    • Blue Icon: Collapse Mode active (New blocks will auto-collapse).
    • Amber Icon: Expand Mode active (New blocks will auto-expand).
  • Toolbar Integration: Adds a native-style button to the top-right toolbar that matches the Google AI Studio aesthetic.

Installation

Requirements

Steps

  1. Install a userscript manager.
  2. Install this script.
  3. Open any prompt in Google AI Studio.

Usage

  1. Locate the button: Look for the chevron icon in the toolbar next to the "More options" (⋮) button.
  2. First Click: Activates Collapse Mode (Blue). All current and future code blocks will stay closed.
  3. Second Click: Switches to Expand Mode (Amber). All current and future code blocks will stay open.
  4. Third Click: Toggles back to Collapse Mode (Blue).

How It Works

  • Persistence: Uses localStorage to remember your toggle state across page reloads and chat switches.
  • Lazy Load Observer: Watches for new ms-code-block elements being added to the DOM and automatically applies your chosen mode (Collapse/Expand) as they appear.
  • Smart Logic: Includes a per-block debounce (500ms) to prevent flickering during rapid scrolling or AI generation.
  • Toolbar Observer: Uses a MutationObserver to ensure the button persists in the toolbar during SPA navigation between chats.

Technical Details

  • Icon: Uses standard Material Symbols (expand_less, expand_more) natively available in the app resources.
  • Styling: Injects minimal CSS to match the native toolbar layout.