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).

这些是此脚本变更过代码的版本。 显示所有版本。

  • v2.6 2026-01-01

    v2.6

    • Cleanup: removed unused RAW_MODE_MENU_DELAY_MS
    • Cleanup: removed unused tooltipTimeout state and dead clearTimeout branch
    • Cleanup: removed unused domOrder field from DOM extraction records
    • Cleanup: removed unreachable if (!scroller) guard (fallback always returns a scroller)
    • Cleanup: replaced console.warn debug dump with structured log(..., 'warn')
  • v2.5 2026-01-01

    v2.3 - V2.5

    • Replaced the default tooltip with a custom Material Design tooltip matching the "Collapse/Expand All Code Blocks" script style.
    • Added dynamic tooltip positioning (above/below button based on available space).
    • Added arrow indicator that points to the button center, even when tooltip is edge-clamped.
    • Added smooth fade-in/fade-out transitions for tooltip visibility.
    • Fixed tooltip to appear instantly on hover (removed 1000ms delay).
    • Fixed tooltip to disappear instantly on mouse leave.
  • v2.2 2025-12-25

    ## Changelog: Version 2.1 → 2.2

    ### New Features

    **First-Time User Hint**
    - Added blue hint banner that appears on first page load
    - Points to the download button, explaining right-click functionality
    - "Don't show again" checkbox to permanently dismiss (persists to storage)
    - Auto-dismisses after 20 seconds or on outside click
    - Smooth fade-in animation with arrow pointing to button

    ### Technical Changes
    - Added `HINT_DISMISSED: false` to `DEFAULT_CONFIG`
    - Hint uses programmatic element creation (CSP-compliant, no `innerHTML`)
    - Hint positioned relative to download button with 12px offset
    - Blue theme (#1a73e8) to distinguish from settings panel

  • v2.1 2025-12-25

    Changelog: Version 2.0 → 2.1

    New Features

    Dual Extraction Mode

    • Added DOM-based extraction as a fallback option alongside XHR
    • New toggle switch in settings panel to switch between XHR (instant) and DOM (scroll-based) modes
    • DOM mode automatically scrolls through conversations, handles lazy-loaded content, and extracts from visible elements

    Silent Raw Mode Toggle

    • DOM mode switches to Raw Mode without visible menu flash
    • Uses synchronous click sequence to prevent browser repaint during menu operations

    Settings Panel Improvements

    • Added close button (✕) in top-right corner of settings panel
    • Added XHR/DOM toggle switch with 1s hover tooltip explaining each mode
    • Toggle tooltip prefers positioning above the element when space allows

    Enhanced Tooltips

    • Improved tooltip positioning to avoid cursor overlap (16px offset)
    • Tooltips now use white-space: pre and width: max-content for proper sizing
    • Added immediate tooltip display during DOM extraction with progress updates
    • Tooltips stay within viewport bounds

    DOM Extraction Capabilities

    • Auto-scrolls through entire conversation to capture all content
    • Preloads history by scrolling to top first (handles virtualized content)
    • Automatically expands collapsed thinking sections
    • Abortable: Click button during extraction to cancel (data discarded)
    • Progress feedback in tooltip during scroll

    Improvements

    Code Architecture

    • Separated markdown generation into generateMarkdownFromXHR() and generateMarkdownFromDOM()
    • Added shared triggerDownload() function
    • Modular DOM extraction module with dedicated constants
    • Added positionTooltip() helper for consistent tooltip positioning

    Title Extraction

    • DOM mode extracts title from ms-toolbar .page-title h1.mode-title selector
    • More reliable title detection from toolbar

    Button States

    • Added WORKING state with red cancel icon during DOM extraction
    • Click button during extraction to abort

    Logging

    • Added warn log type with yellow color (#fbbc04)

    Technical Changes

    New Configuration

    • Added EXTRACTION_MODE: 'xhr' to DEFAULT_CONFIG
    • Settings now persist extraction mode preference

    New State Variables

    • isScrolling - Tracks DOM extraction in progress
    • collectedDOMData - Map for DOM-extracted content
    • scrollCount - Scroll iteration counter
    • abortController - For cancellable DOM extraction

    DOM Constants

    • SCROLL_DELAY_MS: 50 - Fast scroll speed
    • RAW_MODE_MENU_DELAY_MS: 200
    • RAW_MODE_RENDER_DELAY_MS: 300
    • THOUGHT_EXPAND_DELAY_MS: 500
    • MAX_SCROLL_ATTEMPTS: 10000
    • And more timing/threshold constants

    CSS Changes

    • Added .close-button styles for settings panel
    • Added .separator, .toggle-container, .toggle-switch, .toggle-label styles
    • Increased settings panel padding-top to accommodate close button
    • Tooltip uses white-space: pre instead of pre-line

    Bug Fixes

    • Fixed event propagation blocking that prevented toggle switch from working (changed from capture to bubble phase)
  • v2.0 2025-12-25

    Version 2.0 - Major Feature Update

    New Features

    • Multi-endpoint XHR interception: Now captures CreatePrompt and UpdatePrompt in addition to ResolveDriveResource, enabling exports from new chats and mid-conversation updates
    • Thinking block support: Detects and exports model reasoning/thought process blocks
    • Collapsible thinking blocks: Exports thinking as HTML <details> sections for cleaner Markdown
    • Settings panel: Right-click the download button to access customizable export options
    • Persistent settings: User preferences saved via GM_setValue/GM_getValue
    • Configurable export options:
      • Toggle user messages on/off
      • Toggle model responses on/off
      • Toggle thinking blocks on/off
      • Toggle collapsible thinking format
    • Keyboard support: Press Escape to close settings panel
    • Custom tooltip: Hover tooltip explains left-click (export) and right-click (settings)
    • Shadow DOM isolation: Settings panel uses closed Shadow DOM to prevent CSS conflicts
    • Navigation timing safeguard: 2-second debounce prevents data loss when new chat URLs update

    Improvements

    • Structure normalization: Automatically handles different JSON wrapper formats from different endpoints
    • Enhanced turn detection: Uses positions [16] and [19] to distinguish responses from thinking blocks
    • Buffered thinking: Thinking blocks before a response are grouped and exported together
    • Cleaned thinking content: Removes excess newlines while preserving paragraph breaks
    • Harmonized console logs: Consistent formatting and color coding for all log messages
    • Better error messages: Updated alert text to reflect actual behavior (removed "refresh the page" for new chats)

    Technical Changes

    • Version: 1.6 → 2.0
    • Grants: Added GM_setValue, GM_getValue, GM_addStyle
    • Button ID: aistudio-api-export-btnaistudio-xhr-export-btn
    • Terminology: "API-based" → "XHR-based" throughout codebase
    • Timestamp tracking: Added capturedTimestamp for timing-based safeguards

    Bug Fixes

    • Fixed data loss when creating new chats (CreatePrompt → URL change race condition)
    • Fixed missing exports from conversation continuations (UpdatePrompt now intercepted)
  • v1.6 2025-12-21

    Userscript header updated.

  • v1.5 2025-11-30
  • v1.4 2025-11-30
  • v1.3 2025-11-29
  • v1.2 2025-11-29
  • v1.1 2025-11-29
  • v1.1 2025-11-29
  • v1.1 2025-11-29
  • v1.0 2025-11-29