Google AI Studio | Toggle Code Blocks

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

작성자
piknockyou
일일 설치 수
0
총 설치 수
2
평점
0 0 0
버전
1.4
생성일
2025-12-21
갱신일
2025-12-22
크기
10.2KB
라이선스
AGPL-3.0
적용 사이트

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.