I managed to put together a quick and crude script to export an individual chat. This is mostly useful to non-devs like me. Paste this in the browser JS console(command + option + C) and hit enter. You should see a text file downloaded. Repeat this with all your chats and don’t forget to refresh the page before running the code. Hope this helps
// Function to download data as a text file
function download(filename, text) {
var element = document.createElement(‘a’);
element.setAttribute(‘href’, ‘data:text/plain;charset=utf-8,’ + encodeURIComponent(text));
element.setAttribute(‘download’, filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
// Function to collect chat messages
function collectChatMessages() {
let messages = document.querySelectorAll(‘[data-testid^=“conversation-turn-”]’); // Select conversation turns
let chatHistory = ‘’;
messages.forEach(message => {
let authorElement = message.querySelector('[data-message-author-role]');
let textElement = message.querySelector('[data-testid="text-message"]');
let author = authorElement ? authorElement.innerText : 'Unknown';
let text = textElement ? textElement.innerText : '';
chatHistory += `${author}: ${text}\n\n`;
});
return chatHistory;
}
// Collect chat messages and download them
let chatHistory = collectChatMessages();
download(‘chat_history.txt’, chatHistory);