Gemini to Notion Exporter

Gemini 导出:智能图片归位 (支持 PicList/PicGo)+隐私开关+单个对话导出

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Author
wyih
Daily installs
0
Total installs
8
Ratings
0 0 0
Version
13.2
Created
2025-11-23
Updated
2025-12-02
Size
30.4 KB
License
MIT
Applies to

一键将 Gemini 对话导出到 Notion Database。支持 markdown、代码块高亮、表格、图片上传到 PicList(解决 Notion 图片链接失效问题),并能精准将用户上传的图片还原到对话位置。

🚀 Gemini to Notion Exporter

这是目前功能最完善的 Google Gemini 对话导出脚本。它不仅能将对话文本导出到 Notion,还完美解决了图片转存图片位置错乱的两大痛点。(但用户上传的文件无法像图片一样转存)

✨ 核心功能

  1. 📸 PicList/PicGo 无缝集成
    • 脚本会自动拦截 Gemini 中的图片(包括 AI 生成图和用户上传图)。
    • 自动调用本地开启的 PicList/PicGo 服务将图片上传到你配置的图床。
    • 解决痛点:直接复制到 Notion 的图片链接通常是临时的(Google 链接),过段时间会失效。本脚本通过转存图床,确保 Notion 里的图片永久有效。
  2. 🧩 用户图片智能归位
    • 独家功能:很多脚本在导出时,会将用户上传的图片一股脑堆在文末或丢失。
    • 本脚本通过 DOM 分析,能精准地将用户上传的参考图放回对应的 User Query(提问)气泡中,还原真实的对话上下文。
  3. 📝 完美排版支持
    • 支持 Markdown 格式(粗体、斜体、链接)。
    • 支持 代码块(自动检测编程语言,映射到 Notion 支持的语言格式)。
    • 支持 表格(Table)导出。
    • 支持 多级标题列表
  4. ⚡ 批量写入优化
    • 自动处理 Notion API 的 Block 数量限制(每批 100 个),即使是超长对话也能完整导出,不会报错。

🛠️ 准备工作 (必读)

在安装脚本前,请确保你已经准备好以下环境:

1. 配置 Notion

  1. 创建一个新的 Notion Database(数据库),并确保它包含以下 3 个属性(列名必须一致)
    • Name (类型: Title/标题) —— 用于存放对话标题
    • Date (类型: Date/日期) —— 用于记录导出时间 (必须有,否则会报错)
    • URL (类型: URL) —— 用于存放原始对话链接
  2. Notion Integrations 创建一个 Integration,获取 Internal Integration Secret (以 ntn_ 开头)。
  3. 在你的 Database 页面右上角点击 ... -> Connect to -> 选择你刚才创建的 Integration。
  4. 获取 Database ID(在浏览器地址栏 URL 中,?v= 之前的那串 32 位字符)。

2. 配置 PicList (或 PicGo)

为了实现图片转存,你需要安装 PicList (推荐) 或 PicGo。

  1. 打开 PicList 设置 -> 设置 Server。
  2. 开启 Server,并确保端口设置为 36677 (脚本默认连接此端口)。
  3. 确保 PicList 已经配置好了你喜欢的图床(如 Github, S3, Imgur, 阿里云 OSS 等)。
  4. 注意:脚本会以 127.0.0.1:36677 进行通信,请确保没有被防火墙拦截。

📖 使用指南

  1. 安装脚本:点击安装本脚本。
  2. 刷新页面:打开 Google Gemini 页面。
  3. 初次配置
    • 脚本启动时会检测 PicList 心跳。如果连接成功,控制台会显示 ✅ PicList 心跳正常
    • 页面右下角会出现 "📥 Save to Notion" 按钮。
    • 点击按钮,首次运行会提示输入 Notion SecretDatabase ID。输入后会自动保存到本地。
  4. 开始导出
    • 点击按钮后,脚本会变为 🕵️ Analyzing...,开始解析页面并上传图片。
    • 图片上传完成后,状态变为 💾 Creating Page...,开始写入 Notion。
    • 最后显示 ✅ Saved! 即表示完成。

❓ 常见问题 (FAQ)

Q: 点击按钮后提示 "Notion Database 缺少 'Date' 列"? A: 请回到你的 Notion 数据库,添加一个名为 Date 的列,类型选择 Date。这是脚本记录导出时间的依据。

Q: 图片上传失败,提示连接不上 PicList? A: 请检查:

  1. PicList 软件是否已打开?
  2. PicList 设置中 Server 是否已开启?
  3. 端口是否是 36677
  4. 如果是 macOS,可能需要检查网络权限。

Q: 我不想用 PicList,只想导出纯文本行吗? A: 目前版本强依赖 PicList 处理图片。如果未检测到 PicList,图片部分可能会显示为红色错误提示,但文本部分仍会尝试导出。


📝 更新日志

v13.1

  • 🎨 智能吸顶 (Smart Sticky):重新设计按钮定位。无论是长篇回复还是长 Prompt,导出按钮现在都会固定在右上角并跟随滚动。
  • 📐 布局完美适配:采用“双轨制”定位策略(Model 块用 Float,User 块用 Flex),完美解决用户提问框布局错位留白的问题。
  • ✨ 视觉反馈:新增鼠标悬停高亮,划过对话时显示淡蓝色边框,清晰界定操作范围。
  • 🐛 Bug 修复:修复 Notion 导出时 > 引用块 (Blockquote) 无法正确渲染的问题。

v13.0

  • 📤 单条导出:新增单条对话导出功能。点击 User 消息自动组合导出 "问答对",点击 Model 消息仅导出回复。无需每次都全量保存。

v12.0

  • 🔒 隐私模式:新增隐私开关 (👁️/🚫)。可标记单条消息,导出时自动跳过该条内容及其附件,保护敏感数据。
  • 交互优化:将隐私开关移至气泡边缘,减少遮挡。

v11.10

  • 📂 文件优化:针对无后缀的文件链接,根据 MIME 类型自动补全扩展名(支持 PDF, Office, 代码文件等)。

v11.9 (Critical Fixes)

  • 🛡️ 绕过 CSP 限制:改用 Canvas 绘图提取 方案,彻底解决因 Google 安全策略导致的图片上传失败问题。
  • 💾 二进制修复:重构上传模块为标准 FormData API,修复 PDF/Zip 等非文本文件上传损坏的问题。
  • ⚠️ 优雅降级:对无法读取的本地 Blob 文件增加智能检测,转为文本提示而非报错卡死。

v11.6

  • ☁️ 图床对接:正式集成 PicList 本地服务,实现图片永久化存储。
  • ⚡ 核心优化:改进 DOM 解析逻辑修复图片错位;新增 Notion 分批写入逻辑,支持超长对话流畅导出。