Google AI Studio | Conversation/Chat Markdown-Export/Download (XHR/DOM)

Exports the full conversation to Markdown with collapsible thinking blocks. Supports dual extraction modes: XHR (instant, recommended) and DOM (scroll-based fallback).

Você precisará instalar uma extensão como Tampermonkey, Greasemonkey ou Violentmonkey para instalar este script.

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

Você precisará instalar uma extensão como Tampermonkey ou Violentmonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey ou Userscripts para instalar este script.

Você precisará instalar uma extensão como o Tampermonkey para instalar este script.

Você precisará instalar um gerenciador de scripts de usuário para instalar este script.

(Eu já tenho um gerenciador de scripts de usuário, me deixe instalá-lo!)

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

(Eu já possuo um gerenciador de estilos de usuário, me deixar fazer a instalação!)

Autor
piknockyou
Instalações hoje
4
Total de instalações
124
Avaliações
0 0 0
Versão
2.6
Criado
29/11/2025
Atualizado
01/01/2026
Tamanho
68,6 KB
Licença
AGPL-3.0
Aplicável a

See screenshot at the bottom

Google AI Studio | Conversation/Chat Markdown-Export/Download (XHR/DOM)

Instantly export complete Google AI Studio conversations to Markdown. Features dual extraction modes (XHR instant capture + DOM scroll-based fallback), native toolbar integration, configurable export options, collapsible thinking blocks, and seamless support for new chats and navigation.

Features

Dual Extraction Modes

  • XHR Mode (Default, Recommended): Intercepts network endpoints (ResolveDriveResource, CreatePrompt, UpdatePrompt) for instant capture directly from Google's servers. No scrolling required.
  • DOM Mode (Fallback): Automatically scrolls through the conversation and extracts content from visible elements. Useful when XHR capture fails or for edge cases.
  • Easy Toggle: Switch between modes via the settings panel toggle switch.

Full Conversation Lifecycle Support

  • Works on existing saved chats
  • Works on brand new chats (first message)
  • Works when continuing conversations
  • Automatically updates when switching between chats

Thinking Block Support

  • Captures and exports the model's internal "thinking" or "reasoning" content
  • Toggle inclusion on/off via settings
  • Collapsible <details> sections for cleaner readability (optional)

Customizable Export Settings (Right-click the button)

  • Toggle User Messages
  • Toggle Model Responses
  • Toggle Thinking Blocks
  • Toggle Collapsible Thinking (HTML details/summary)
  • Switch between XHR and DOM extraction modes
  • Settings persist across sessions

Additional Features

  • Instant Capture: No scrolling, no waiting in XHR mode. Data captured the moment it arrives.
  • Seamless SPA Navigation: Handles AI Studio's Single Page Application design flawlessly.
  • Smart Timing Protection: 2-second debounce prevents data loss during new chat URL updates.
  • Smart Recursive Parsing: Advanced algorithm locates chat history regardless of JSON structure changes.
  • Native Toolbar Integration: Seamless download button using Material Design styling.
  • Clean Markdown Output: Well-formatted .md files ready for archiving or use with other tools.
  • Keyboard Support: Press Escape to close the settings panel.
  • Silent Raw Mode Toggle: DOM mode switches to Raw Mode silently (no visible menu flash) for cleaner extraction.

Installation

Requirements

Steps

  1. Install one of the userscript managers listed above.
  2. Click the install button for this script.
  3. The script will automatically activate on https://aistudio.google.com/*.

Usage

Basic Export

  1. Navigate to any conversation in Google AI Studio (new or existing).
  2. Look for the Download Icon (green) in the top-right toolbar.
  3. Left-click the button to instantly download the Markdown (.md) file.
  4. Switching Chats? Just click a different prompt in the sidebar. The script automatically detects the new network response and is ready to export immediately.

Customize Export Settings

  1. Right-click the download button.
  2. A settings panel appears with:
    • Include User Messages: Toggle your own prompts in the export.
    • Include Model Responses: Toggle AI responses in the export.
    • Include Thinking: Toggle the model's reasoning/thought process (sub-option of Model Responses).
    • Collapsible Thinking: Export thinking blocks as collapsible sections (sub-option of Include Thinking).
    • Extraction Method Toggle: Switch between XHR (instant) and DOM (scroll-based) modes.
  3. Close the panel by:
    • Clicking the ✕ button in the top-right corner
    • Clicking outside the panel
    • Pressing Escape
  4. Your settings are saved automatically and persist across sessions.

When to Use DOM Mode

DOM mode is provided as a fallback for situations where XHR capture might not work:

  • If XHR mode reports "No data available" but you can see the conversation
  • For debugging or verification purposes
  • When network interception is blocked

In DOM mode, the script will:

  1. Silently switch to Raw Mode (if not already)
  2. Scroll through the entire conversation automatically
  3. Extract all visible content
  4. Restore the original view mode
  5. Download the Markdown file

How It Works

XHR Mode (Default)

Unlike traditional scrapers that read text from the rendered page, this script uses a more robust approach:

  1. XHR Interception: Extends XMLHttpRequest.prototype to listen for three specific endpoints:
    • ResolveDriveResource (loading existing chats)
    • CreatePrompt (creating new chats)
    • UpdatePrompt (continuing conversations)
  2. Data Capture: Google sends full conversation history as JSON. The script silently captures this data.
  3. Structure Normalization: Different endpoints return different JSON wrapper formats. The script normalizes them.
  4. Recursive Search: Scans deeply nested JSON to find dialogue turns, regardless of structure.
  5. Turn Classification: Analyzes each turn using array positions [8], [16], [19] to identify user messages, model responses, and thinking blocks.
  6. Markdown Formatting: Converts data into clean Markdown with optional collapsible thinking blocks.
  7. Download: Generates a file named after the chat title and triggers browser download.

DOM Mode (Fallback)

When XHR mode isn't suitable, DOM mode provides an alternative:

  1. Mode Detection: Checks if page is in Raw Mode or Rendered Mode.
  2. Silent Raw Mode Toggle: Switches to Raw Mode without visible menu flash for cleaner extraction.
  3. Auto-Scroll: Scrolls through the entire conversation to load all virtualized content.
  4. Element Extraction: Captures text from DOM elements (ms-chat-turn, ms-text-chunk, etc.).
  5. Thinking Expansion: Automatically expands collapsed thinking sections.
  6. Mode Restoration: Returns to original view mode after extraction.
  7. Markdown Generation: Same formatting as XHR mode for consistent output.

Technical Details

XHR Mode

  • Transport: Captures XMLHttpRequest (XHR) responses only.
  • Data Completeness: Each network response contains the full conversation state.
  • Thinking Detection: Position [19] === 1 in turn array.
  • Response Detection: Position [16] === 1 in turn array.
  • Navigation Safety: 2-second timestamp buffer prevents premature data clearing.

DOM Mode

  • Scroll Speed: 50ms delay between scroll steps for fast extraction.
  • Raw Mode: Automatically switches for reliable text extraction.
  • Silent Toggle: Menu operations executed synchronously to prevent visual flash.
  • Abort Support: Click button during extraction to cancel (data discarded).

FAQ

Q: I don't see the button.
A: If you just installed the script, refresh the page once. The button appears automatically after the toolbar loads.

Q: Can I export a brand new chat I just started?
A: Yes! After the first AI response completes, the data is captured and ready to export immediately.

Q: Does this send my data anywhere?
A: No. The script runs entirely locally in your browser. It only converts the data Google already sent you into a text file.

Q: When should I use DOM mode instead of XHR mode?
A: XHR mode is recommended for most cases. Use DOM mode only if XHR reports "No data available" but you can see the conversation on screen.

Q: Why do thinking blocks appear as HTML in my Markdown viewer?
A: Collapsible sections use <details> tags, which are valid HTML inside Markdown. Most modern renderers (GitHub, Obsidian, VSCode) support them natively.

Q: Can I disable thinking blocks entirely?
A: Yes. Right-click the download button and uncheck "Include Thinking."

Q: Can I abort DOM mode extraction?
A: Yes. Click the button while extraction is in progress (it shows a red cancel icon). All captured data will be discarded.

Q: Does DOM mode work with long conversations?
A: Yes. DOM mode automatically scrolls through the entire conversation, handling lazy-loaded content. However, very long conversations may take several seconds.