Google AI Studio Conversation Export Tool
背景与动机
Google AI Studio 提供了优秀的对话体验。但在科研或日常记录中,我们常面临数据留存的难题。原生界面并未提供导出选项。
若要保存灵感、整理代码片段或备份团队协作内容,逐条复制粘贴显然过于低效。这种重复性劳动不应占据宝贵的时间。
为此,编写了一款基于 Tampermonkey 的用户脚本:AI Studio Chat Exporter。它旨在解决这一痛点,实现对话内容的一键打包。
功能概述
该脚本主要实现了以下几项功能,旨在简化数据获取流程:
一键导出
页面加载完成后,屏幕上会出现一个悬浮的 “Export JSON” 按钮。点击它,即可将当前的聊天内容打包成 JSON 文件并下载。完整抓取
脚本会自动处理页面的滚动加载。这确保了每一轮对话——无论是用户的输入还是模型的回复——都能被完整收录,避免了手动复制可能产生的遗漏。系统提示词提取
System Prompt 往往定义了对话的基调和规则。即使侧边栏处于折叠状态,脚本也会自动展开并捕获这部分关键信息。Markdown 格式支持
模型输出中的标题、列表、代码块等元素,会被转换为标准的 Markdown 格式。这使得导出的内容可以直接粘贴到笔记软件或博客中,无需二次排版。多语言适配
界面提示词支持简体中文、英文、德语等多种语言,会根据浏览器的语言设置自动切换。
部署方法
使用该脚本需要浏览器扩展程序的支持。
环境准备
在 Chrome、Edge 或 Brave 等浏览器中安装 Tampermonkey (油猴) 扩展。脚本安装
获取script.js脚本文件或链接。Tampermonkey 会自动识别并弹出安装界面,点击 “Install” 即可。
点此安装权限确认
确保脚本的匹配规则覆盖了https://aistudio.google.com/prompts/*这一域名。生效验证
刷新 AI Studio 的对话页面。若页面顶部出现一个可拖拽的蓝色按钮,即表示安装成功。
使用说明
操作流程非常直观:
- 打开任意一个 AI Studio 对话项目。
- 找到悬浮按钮,将其拖动到不遮挡视线的位置。
- 点击按钮。脚本将自动执行以下操作:
- 获取系统提示词 (System Instruction)。
- 滚动并加载所有历史对话。
- 将内容格式化为 Markdown。
- 生成并下载 JSON 文件。
文件默认以当前项目的标题命名,例如 My_Project.json。
数据结构
导出的 JSON 文件结构清晰,便于程序二次处理或人工阅读:
1 | |
注意事项
在使用过程中,可能会遇到一些细微的情况:
- 按钮未显示:请检查 Tampermonkey 扩展是否已启用,或者尝试刷新页面。
- 导出内容为空:脚本依赖于页面的 DOM 结构。请确保对话区域已正常加载,且能够滚动。
- System Prompt 字段为空:并非所有对话都设置了系统提示词。若原项目未设置,该字段自然为空。
- 权限提示:脚本更新时,Tampermonkey 可能会请求新的地址权限,允许即可。
结语
AI Studio Chat Exporter 将繁琐的备份工作简化为一个点击动作。这不仅节省了时间,也让知识管理变得// filepath: x:\GitHub\hexo\source_posts\aistudio-dump-script.md
title: Google AI Studio 对话导出工具
date: 2025-12-04 15:11:53
author: Tokisaki Galaxy
excerpt: 针对 Google AI Studio 缺少原生导出功能的问题,开发了一款基于 Tampermonkey 的用户脚本。该脚本可将对话内容完整抓取并导出为 JSON 格式,支持 Markdown 渲染,便于后续的资料整理与归档。
tags:
- Tampermonkey
- Google AI Studio
- 效率工具
- JavaScript
categories:
- 效率工具
背景与动机
Google AI Studio 提供了优秀的对话体验。但在科研或日常记录中,我们常面临数据留存的难题。原生界面并未提供导出选项。
若要保存灵感、整理代码片段或备份团队协作内容,逐条复制粘贴显然过于低效。这种重复性劳动不应占据宝贵的时间。
为此,编写了一款基于 Tampermonkey 的用户脚本:AI Studio Chat Exporter。它旨在解决这一痛点,实现对话内容的一键打包。
功能概述
该脚本主要实现了以下几项功能,旨在简化数据获取流程:
一键导出
页面加载完成后,屏幕上会出现一个悬浮的 “Export JSON” 按钮。点击它,即可将当前的聊天内容打包成 JSON 文件并下载。完整抓取
脚本会自动处理页面的滚动加载。这确保了每一轮对话——无论是用户的输入还是模型的回复——都能被完整收录,避免了手动复制可能产生的遗漏。系统提示词提取
System Prompt 往往定义了对话的基调和规则。即使侧边栏处于折叠状态,脚本也会自动展开并捕获这部分关键信息。Markdown 格式支持
模型输出中的标题、列表、代码块等元素,会被转换为标准的 Markdown 格式。这使得导出的内容可以直接粘贴到笔记软件或博客中,无需二次排版。多语言适配
界面提示词支持简体中文、英文、德语等多种语言,会根据浏览器的语言设置自动切换。
部署方法
使用该脚本需要浏览器扩展程序的支持。
环境准备
在 Chrome、Edge 或 Brave 等浏览器中安装 Tampermonkey (油猴) 扩展。脚本安装
获取script.js脚本文件或链接。Tampermonkey 会自动识别并弹出安装界面,点击 “Install” 即可。权限确认
确保脚本的匹配规则覆盖了https://aistudio.google.com/prompts/*这一域名。生效验证
刷新 AI Studio 的对话页面。若页面顶部出现一个可拖拽的蓝色按钮,即表示安装成功。
使用说明
操作流程非常直观:
- 打开任意一个 AI Studio 对话项目。
- 找到悬浮按钮,将其拖动到不遮挡视线的位置。
- 点击按钮。脚本将自动执行以下操作:
- 获取系统提示词 (System Instruction)。
- 滚动并加载所有历史对话。
- 将内容格式化为 Markdown。
- 生成并下载 JSON 文件。
文件默认以当前项目的标题命名,例如 My_Project.json。
数据结构
导出的 JSON 文件结构清晰,便于程序二次处理或人工阅读:
1 | |
注意事项
在使用过程中,可能会遇到一些细微的情况:
- 按钮未显示:请检查 Tampermonkey 扩展是否已启用,或者尝试刷新页面。
- 导出内容为空:脚本依赖于页面的 DOM 结构。请确保对话区域已正常加载,且能够滚动。
- System Prompt 字段为空:并非所有对话都设置了系统提示词。若原项目未设置,该字段自然为空。
- 权限提示:脚本更新时,Tampermonkey 可能会请求新的地址权限,允许即可。
结语
AI Studio Chat Exporter 将繁琐的备份工作简化为一个点击动作。这不仅节省了时间,也让知识管理变得更加有序。希望这个小工具能为各位的研究与工作带来便利。
Background and Motivation
Google AI Studio offers an excellent conversational experience. However, in research or daily note-taking, we often face challenges with data retention. The native interface does not provide an export option.
Tasks like saving ideas, organizing code snippets, or backing up collaborative content are inefficient if done by copying and pasting each piece. Such repetitive work should not consume valuable time.
To address this pain point, a Tampermonkey userscript named AI Studio Chat Exporter has been developed. It aims to solve this issue by enabling one-click packaging of conversation content.
Feature Overview
This script mainly implements the following features to simplify the data acquisition process:
One-Click Export
After the page loads, a floating “Export JSON” button appears on the screen. Clicking it packages the current chat into a JSON file for download.Complete Capture
The script automatically handles page scroll loading. This ensures every conversation turn—whether user input or model response—is fully captured, avoiding omissions that can occur with manual copying.System Prompt Extraction
The System Prompt often defines the conversation’s tone and rules. Even if the sidebar is collapsed, the script automatically expands it and captures this crucial information.Markdown Format Support
Elements like headings, lists, and code blocks in the model’s output are converted into standard Markdown format. This allows exported content to be directly pasted into note-taking apps or blogs without additional formatting.Multi-Language Adaptation
Interface labels support Simplified Chinese, English, German, and other languages, switching automatically based on the browser’s language settings.
Deployment Method
Using this script requires browser extension support.
Environment Setup
Install the Tampermonkey extension in browsers like Chrome, Edge, or Brave.Script Installation
Obtain thescript.jsscript file or link. Tampermonkey automatically detects it and prompts for installation. Click “Install”.
Install HerePermission Confirmation
Ensure the script’s matching rules cover the domainhttps://aistudio.google.com/prompts/*.Verification
Refresh any AI Studio conversation page. If a draggable blue button appears at the top of the page, installation was successful.
Usage Instructions
The process is very intuitive:
- Open any AI Studio conversation project.
- Locate the floating button and drag it to a position that doesn’t obstruct your view.
- Click the button. The script will automatically perform the following:
- Retrieve the system prompt (System Instruction).
- Scroll and load all historical conversations.
- Format the content into Markdown.
- Generate and download a JSON file.
The file is named after the current project title by default, e.g., My_Project.json.
Data Structure
The exported JSON file has a clear structure, facilitating secondary program processing or manual reading:
1 | |
Notes
You may encounter some specific situations during use:
- Button Not Displayed: Check if the Tampermonkey extension is enabled, or try refreshing the page.
- Empty Export Content: The script relies on the page’s DOM structure. Ensure the conversation area is loaded and scrollable.
- Empty System Prompt Field: Not all conversations have a system prompt set. This field will be empty if the original project didn’t set one.
- Permission Prompt: When the script is updated, Tampermonkey might request permission for new addresses. Granting this is necessary.
Conclusion
AI Studio Chat Exporter simplifies tedious backup work into a single click. This not only saves time but also makes knowledge management more orderly. It is hoped that this small tool will bring convenience to your research and work.