Last active
July 23, 2026 20:42
-
-
Save billywhizz/6cfe1ed9a8f192a53a576359b82c5711 to your computer and use it in GitHub Desktop.
ChatGPT convo history bookmarklet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getDatabase (name = 'ConversationsDatabase') { | |
| const req = window.indexedDB.open(name) | |
| return new Promise((resolve, reject) => { | |
| req.onsuccess = e => resolve(req.result) | |
| req.onerror = req.onabort = reject | |
| }) | |
| } | |
| function getAllKeys (db, collection = 'conversations') { | |
| const req = db.transaction([collection], 'readonly').objectStore(collection).getAllKeys() | |
| return new Promise((resolve, reject) => { | |
| req.onsuccess = e => resolve(req.result) | |
| req.onerror = req.onabort = reject | |
| }) | |
| } | |
| function getByKey (db, key, collection = 'conversations') { | |
| const req = db.transaction([collection], 'readonly').objectStore(collection).get(key) | |
| return new Promise((resolve, reject) => { | |
| req.onsuccess = e => resolve(req.result) | |
| req.onerror = req.onabort = reject | |
| }) | |
| } | |
| function fileName (path) { | |
| return path.slice(path.lastIndexOf('/') + 1) | |
| } | |
| let database | |
| getDatabase() | |
| .then(db => { | |
| database = db | |
| return getAllKeys(db) | |
| }) | |
| .then(keys => { | |
| return Promise.all(keys.map(k => getByKey(database, k))) | |
| }) | |
| .then(all => { | |
| const link = document.createElement('a') | |
| const blob = new Blob([JSON.stringify(all, null, ' ')], { type: 'application/json' } ) | |
| link.href = URL.createObjectURL(blob) | |
| link.download = fileName("conversations.json") | |
| link.click() | |
| })})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function()%7Bfunction getDatabase (name %3D 'ConversationsDatabase') %7B%0A const req %3D window.indexedDB.open(name)%0A return new Promise((resolve%2C reject) %3D> %7B%0A req.onsuccess %3D e %3D> resolve(req.result)%0A req.onerror %3D req.onabort %3D reject%0A %7D)%0A%7D%0A%0Afunction getAllKeys (db%2C collection %3D 'conversations') %7B%0A const req %3D db.transaction(%5Bcollection%5D%2C 'readonly').objectStore(collection).getAllKeys()%0A return new Promise((resolve%2C reject) %3D> %7B%0A req.onsuccess %3D e %3D> resolve(req.result)%0A req.onerror %3D req.onabort %3D reject%0A %7D)%0A%7D%0A%0Afunction getByKey (db%2C key%2C collection %3D 'conversations') %7B%0A const req %3D db.transaction(%5Bcollection%5D%2C 'readonly').objectStore(collection).get(key)%0A return new Promise((resolve%2C reject) %3D> %7B%0A req.onsuccess %3D e %3D> resolve(req.result)%0A req.onerror %3D req.onabort %3D reject%0A %7D)%0A%7D%0A%0Afunction fileName (path) %7B%0A return path.slice(path.lastIndexOf('%2F') %2B 1)%0A%7D%0A%0Alet database%0A%0AgetDatabase()%0A .then(db %3D> %7B%0A database %3D db%0A return getAllKeys(db)%0A %7D)%0A .then(keys %3D> %7B%0A return Promise.all(keys.map(k %3D> getByKey(database%2C k)))%0A %7D)%0A .then(all %3D> %7B%0A const link %3D document.createElement('a')%0A const blob %3D new Blob(%5BJSON.stringify(all%2C null%2C ' ')%5D%2C %7B type%3A 'application%2Fjson' %7D )%0A link.href %3D URL.createObjectURL(blob)%0A link.download %3D fileName("conversations.json")%0A link.click()%0A %7D)%7D)()%3B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment