A Tampermonkey userscript for syncing ChatGPT conversations to Supabase database.
This userscript allows you to capture and sync ChatGPT conversations directly from the web interface to your Supabase database with a single click. It uses ChatGPT's backend API for reliable data extraction and includes fallback DOM scraping.
- 🚀 One-click sync to Supabase
- 📚 Batch sync up to 20 recent conversations from homepage
- 🔄 API-first approach with DOM fallback
- ⌨️ Keyboard shortcut support (Ctrl/⌘+Shift+S)
- 🔒 Duplicate detection and prevention
- 📱 Support for regular and shared ChatGPT links
- 🎯 Clean data extraction (removes UI clutter)
- 📄 Upload any web page to Supabase as Markdown
- 🔄 HTML to Markdown conversion with structure preservation
- 🌐 Works on all websites via Tampermonkey menu
- 🔁 Auto UPSERT based on page URL
- 🌙 Dark mode support
- 🔧 Easy configuration via Supabase dashboard
- Set up Supabase database - See SETUP.md for detailed instructions
- Install the userscript in Tampermonkey/Violentmonkey
- Configure your Supabase credentials on first use
- Start syncing conversations or uploading pages
Install directly from the raw GitHub URL in your userscript manager:
- Direct install:
https://raw.githubusercontent.com/chyx/chat-syncer/main/chat-syncer-unified.user.js - Auto-updates: Enabled via @updateURL and @downloadURL directives
The unified script includes both ChatGPT syncing and Supabase config helper functionality.
- Install the unified userscript
- Go to your Supabase project → Settings → API
- Click the "🚀 配置 ChatGPT Syncer" button (top-right)
- Click "🚀 直接保存配置" - no copying needed!
- Go to ChatGPT and start syncing
- Navigate to any ChatGPT conversation
- Click the "Sync → Supabase" button (bottom-right corner)
- Or use keyboard shortcut:
Ctrl/⌘ + Shift + S
- Go to ChatGPT homepage (https://chatgpt.com/)
- Click the "📚 批量同步最近20条" button (bottom-right corner)
- Monitor progress in the popup modal
- Duplicate conversations are automatically skipped
- Navigate to any web page
- Click Tampermonkey icon → "Upload Page"
- Page content is converted to Markdown and uploaded to Supabase
- Same URL = update existing record (UPSERT)
To get the latest uploaded pages from Supabase:
-- Get the most recent 10 uploads
SELECT page_url, page_title, updated_at, page_content
FROM page_uploads
ORDER BY updated_at DESC
LIMIT 10;
-- Get a specific page by URL
SELECT * FROM page_uploads
WHERE page_url = 'https://example.com/page';
-- Search pages by title or content
SELECT page_url, page_title, updated_at
FROM page_uploads
WHERE page_title ILIKE '%search term%'
OR page_content ILIKE '%search term%'
ORDER BY updated_at DESC;Or use Supabase client library:
// Get latest uploads
const { data, error } = await supabase
.from('page_uploads')
.select('page_url, page_title, updated_at, page_content')
.order('updated_at', { ascending: false })
.limit(10);If auto-detection fails, you can manually configure:
- Click sync button on any ChatGPT page
- Fill in Supabase URL, API key, and table name in the modal
📖 See SETUP.md for complete database setup instructions
Quick links:
- ChatGPT Sync Setup - chat_logs table
- Page Upload Setup - page_uploads table
- Troubleshooting - Common issues and solutions
- Query Examples - Useful SQL queries
Each synced conversation is stored as a single row containing:
- Basic info: chat_id, chat_url, chat_title, timestamps
- Messages array:
[{idx, role, text, html}, ...] - Metadata: user agent, source method (api/dom), viewport info
Each uploaded web page contains:
- Page info: page_url (unique), page_title, created_at, updated_at
- Content: page_content (Markdown format)
- Metadata: user agent, viewport, content length
See SETUP.md for detailed table schemas and security policies.
src/
├── config.js - Theme, CONFIG, PageDetector
├── chatgpt.js - ChatGPT module (UI, batch sync, data extraction)
├── supabase.js - Supabase module (config helper, auto-detection)
├── page-uploader.js - Page upload module (HTML→Markdown, upload)
└── main.js - Initialization logic
build.js - Build script to generate chat-syncer-unified.user.js
SETUP.md - Complete database setup guide
npm run build # Generate chat-syncer-unified.user.js from source files
npm test # Run test suiteThe chat-syncer-unified.user.js file is generated from source files in src/. Always edit source files, not the generated file.
Version is managed in package.json and automatically injected into the userscript header during build.
MIT