ChatGPT Save Conversation

人民的勤务员
2025-05-29T15:32:13Z

Save the conversation as a .txt file

简体中文 | English | 한국어 | Tiếng Việt | 繁體中文
👆️access GitHub Readme file on for a better experience。

GitHubView the serviceman’s scriptGithub:@ChinaGodMan
GreasyForkView the serviceman’s script
View the serviceman’s script on the current page

⭐If the script helps you,Can light up the stars to encourage⭐

Recommended use：

💡 Tip: The script manager and browser listed above do not represent all
The script runs normally in the following environment

ChatGPT Save conversation

「 Save the conversation as a .txt file 」

Download:Github | ⭐Greasy Fork

Update records

🛠️ ChatGPT Save the conversation Update log

📅 2025.6.3.1

Revise: Change the button color to green,Convenient identification

Introduction to the chat content save button script

Automatically add a fixed position“Save the conversation”Button，After clicking the button, the chat conversation content in the current page will be extracted and saved as a plain text file.，Convenient to users export and backup chat history。

Main functions

Extract chat messages
From all included in the page data-message-id Elements of attributes extract conversation content，And according to data-message-author-role Attribute judgment role（User / Assistant wait）。

Format text
according to Character name: Line break，Write the corresponding text content，Use between each messageSeparationsymbol --- Separation。

Generate file name
Priority to the use of web titles40characters as file name，If there is no title, start with the dialogue5Lowercase splicing of words as file names，The default file name is conversation.txt。

Download text file
use Blob Object creation download link，Simulate click to download the conversation content text file。

Interface interaction
A small button is displayed in the upper left corner of the page，Click to save the current conversation。

Code structure description

capitalizeRole(role)：Format the initial letter of the role based on the role string。

generateFileName(messages)：Generate file name based on page title or first message。

saveConversation()：Core Functions，Collect message content、format、Generate file and trigger download。

createDownloadButton()：Create and add a fixed one“Save the conversation”Button to page。

waitForBody Timer：Wait for the page body and chat messages to complete the loading of buttons。

How to use

1. Add this script to the browser user script manager（like Tampermonkey）。

2. Open a web page with chat conversations（Support with data-message-id and data-message-author-role The structure of attributes）。

3. The upper left corner of the page appears“Save the conversation”Button，After clicking, you can export the current chat content as .txt document。

Applicable scenarios

Export and backup web chat history。

View conversation content offline。

Convenient to share or archive chat text。

Things to note

Depend on page structure，Require message node to have data-message-id and data-message-author-role property。

Extract only with .whitespace-pre-wrap or .markdown Text content of class。

Simple and fixed button style，The location can be customized as needed。

This script is suitable for users who need to quickly save web chat history。

💖 The script referenced or used the following script:

🧑‍💻 @Taylor-eOS ⇒ 📜 Save Conversation