Export AI Studio conversations to Markdown with intelligent mode detection, toolbar integration, and abortable processing. Features dual-mode extraction and configurable filters.
目前為
# Google AI Studio | Chat MarkDown-Export
This userscript provides advanced conversation export capabilities for Google AI Studio, allowing users to export chat conversations to Markdown format with intelligent mode detection, abortable processing, and configurable export filters. The script integrates seamlessly into the AI Studio toolbar and provides a solution for conversation capture and archiving.
## Features
- **Intelligent Mode Detection**: Automatically detects Raw Mode vs Rendered Mode and adapts extraction strategy accordingly
- **Abortable Processing**: Cancel extraction mid-process with the click of a button for responsive user experience
- **Toolbar Integration**: Seamlessly integrated into AI Studio's existing toolbar with native Material Design styling
- **Configurable Export Filters**: Real-time control over what content to include in exports (user messages, AI responses, AI thinking)
- **High-Performance Scrolling**: Ultra-fast scrolling with 50ms delays and intelligent batching for maximum speed
- **Auto-Recovery**: Automatically handles dynamic UI re-rendering and maintains functionality across navigation
- **Dual-Mode Support**: Works with both Raw Mode (clean markdown) and Rendered Mode (formatted content)
- **CSP-Compliant**: Fully compliant with AI Studio's Content Security Policy restrictions
- **Advanced Content Extraction**: Captures user prompts, AI responses, and AI thinking/reasoning processes
- **Visual State Feedback**: Button shows current status (Idle/Working/Success/Error) with appropriate Material Design icons
## Installation
### Requirements
- A userscript manager browser extension:
- [Violentmonkey](https://violentmonkey.github.io/) (recommended)
- [Tampermonkey](https://www.tampermonkey.net/)
### Steps
1. Install one of the userscript managers listed above
2. Download the script file
3. Import the script into your userscript manager
4. The script will automatically activate on `https://aistudio.google.com/*`
## Usage
1. Navigate to any conversation page in Google AI Studio
2. Look for the export/download icon in the top toolbar
3. (Optional) Click the settings gear icon to configure export filters:
- Toggle Raw Mode preference
- Include/exclude user messages
- Include/exclude AI responses
- Include/exclude AI thinking/reasoning
4. Click the export button to begin automated capture
5. Monitor progress via button state changes (working → success/error)
6. Click the button again during processing to abort if needed
7. Download starts automatically when extraction is complete
## How It Works
The script automates the complete conversation export process:
1. **Mode Detection**: Automatically detects current page mode (Raw vs Rendered)
2. **Mode Toggle** (if needed): Switches to preferred mode for optimal extraction
3. **High-Speed Scrolling**: Performs ultra-fast automated scrolling through the entire conversation
4. **Smart Content Extraction**: Captures user prompts, AI responses, and thinking processes in real-time
5. **Expandable Sections**: Automatically expands collapsed thinking/reasoning sections before extraction
6. **Final Verification**: Performs multiple collection passes to ensure complete capture
7. **Markdown Generation**: Formats captured content into clean, structured Markdown
8. **File Download**: Automatically downloads the formatted export file
This entire process is reduced to a single button click in the toolbar.
## Compatibility
- **Browser**: Chrome, Firefox, Safari, Edge
- **Userscript Manager**: Violentmonkey, Tampermonkey, Greasemonkey
- **Platform**: Google AI Studio (aistudio.google.com)
- **Page Types**: Prompt conversations, chat sessions, thinking processes
## Technical Details
- **Language**: JavaScript (ES6+)
- **Framework**: None (vanilla JavaScript)
- **Dependencies**: None
- **CSP Compliant**: Uses Trusted Types and DOM manipulation to avoid Content Security Policy restrictions
- **Architecture**: MutationObserver for dynamic UI handling, AbortController for cancellation
- **Performance**: 50ms scroll delays with intelligent batching and final verification passes
## Configuration
The script includes runtime-configurable settings accessible via the settings panel:
```javascript
// Core preferences
let PREFER_RAW_MODE = true; // Auto-switch to Raw Mode for cleaner extraction
let INCLUDE_USER_MESSAGES = true; // Include user prompts in export
let INCLUDE_AI_RESPONSES = true; // Include AI answers in export
let INCLUDE_AI_THINKING = false; // Include AI reasoning/thought process
```
## Credits & Inspiration
This script builds upon concepts from two projects:
1. **MaxTab's UserScript**
- User:
- Script:
- Core extraction logic and scroll automation techniques
2. **Gemini2PDF Extension**
- Developer: Hamza Wasim ()
- Extension:
- Website:
- UI integration patterns and advanced extraction strategies