Skip to content

Instantly share code, notes, and snippets.

@shinshin86
Created January 11, 2023 13:44
Show Gist options
  • Save shinshin86/f5bb621ec537a373fa2cc6da203d2307 to your computer and use it in GitHub Desktop.
Save shinshin86/f5bb621ec537a373fa2cc6da203d2307 to your computer and use it in GitHub Desktop.
ChatGPT conversation downloader
/**
* ChatGPT conversation downloader
*
* Usage:
* 1. Open the ChatGPT page.
* 2. Open the console from your browser's developer tools (DevTools for Chrome), paste this script and run it.
* 3. Next, run `download()` with the conversation you want to download selected from the history.
* 4. The conversation will then be downloaded as a text file.
* 5. The title of the text file will be the title name in the history.
*
* Note:
* this script will be disabled if the screen specification of ChatGPT is updated.
*/
const download = () => {
const title = document.querySelector('.pr-14.bg-gray-800').text;
const textList = []
document.querySelectorAll('.text-base').forEach((t, i) => {
textList.push(`${i % 2 === 0 ? "Q:" : "A:"} ${t.textContent}`)
})
const text = textList.join('\n');
const blob = new Blob([text], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = title;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment