Skip to content

Fix ChatGPT virtualized exports, formatting, and Unicode filenames#16

Open
Misaka-Mikoto-Tech wants to merge 3 commits into
revivalstack:mainfrom
Misaka-Mikoto-Tech:main
Open

Fix ChatGPT virtualized exports, formatting, and Unicode filenames#16
Misaka-Mikoto-Tech wants to merge 3 commits into
revivalstack:mainfrom
Misaka-Mikoto-Tech:main

Conversation

@Misaka-Mikoto-Tech

@Misaka-Mikoto-Tech Misaka-Mikoto-Tech commented Jun 11, 2026

Copy link
Copy Markdown

Summary

  • Cache ChatGPT conversation turns by their stable conversation-turn-N test id so previously loaded messages are not lost when ChatGPT virtualizes the DOM.
  • Rebuild ChatGPT export data from the accumulated cache instead of only the currently mounted DOM nodes.
  • Attach a debounced scroll listener for ChatGPT so the outline refreshes and accumulates turns as the user scrolls through a conversation.
  • Preserve ChatGPT assistant replies that contain multiple rendered markdown blocks in the same turn.
  • Preserve line breaks in ChatGPT CodeMirror code blocks after cloning cached content for export.
  • Export multiline ChatGPT user inline-code prompts as fenced code blocks so prompt code keeps its line breaks.
  • Preserve Unicode letters and numbers in exported Markdown filenames so non-ASCII conversation titles, such as Chinese titles, are not replaced with hyphens.
  • Add lightweight regression coverage for virtualized turns, multi-block assistant replies, cloned CodeMirror blocks, multiline user code prompts, and Unicode filename sanitization.

Problems fixed

  1. ChatGPT virtualizes long conversations: only part of the thread is mounted in the DOM at once. The exporter rebuilt its outline from the currently mounted nodes, so the number of exportable items changed while scrolling and long conversations could export incomplete content.
  2. Some ChatGPT content blocks lost formatting during export. In particular, assistant turns can contain multiple markdown blocks, cloned CodeMirror blocks can lose visible line breaks, and multiline user prompts rendered as inline-code could be flattened instead of preserved as code blocks.
  3. Exported Markdown filenames stripped non-ASCII characters from conversation titles, causing titles with Chinese or other Unicode text to be replaced with hyphenated or incomplete filenames.

Validation

  • Verified manually on a ChatGPT conversation that previously showed an incomplete/changing outline; after refreshing with this userscript, all 7 user turns are shown.
  • Verified manually that previously missing assistant content is included in the exported Markdown.
  • Verified manually that ChatGPT-exported code blocks and multiline prompt code preserve line breaks.
  • Verified manually that Markdown export filenames preserve Chinese characters from the conversation title.
  • Ran node tools/test-chatgpt-virtual-scroll-cache.js.
  • Ran node --check ai-chat-exporter.user.js.
  • Ran node --check tools/test-chatgpt-virtual-scroll-cache.js.

@Misaka-Mikoto-Tech Misaka-Mikoto-Tech changed the title Fix ChatGPT exports for virtualized conversations Fix ChatGPT virtualized exports and code formatting Jun 11, 2026
@Misaka-Mikoto-Tech Misaka-Mikoto-Tech changed the title Fix ChatGPT virtualized exports and code formatting Fix ChatGPT exports for virtualized conversations, formatting, and filenames Jun 11, 2026
@Misaka-Mikoto-Tech Misaka-Mikoto-Tech changed the title Fix ChatGPT exports for virtualized conversations, formatting, and filenames Fix ChatGPT virtualized exports, formatting, and Unicode filenames Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant