ChatGPT AutoCleaner v5

Bugfix & speed-up for ChatGPT: automatically cleans the conversation chat window by trimming old messages (both in DOM and React memory). Keeps only the latest N turns visible, preventing lag and memory bloat on long sessions. Includes manual “Clean now” button and skips auto-clean when the tab is hidden.

目前為 2025-08-16 提交的版本,檢視 最新版本

作者
Aleksey Maximov
評價
0 0 0
版本
1.1
建立日期
2025-07-26
更新日期
2025-08-16
尺寸
12.3 KB
授權條款
MIT
腳本執行於

TL;DR

  • The problem is well known — everyone complains that long single-thread chats become painfully slow.
  • The UI is a sluggish React app, and OpenAI hasn’t fixed the lag/memory leaks for ages.
  • This script applies a “dirty but safe” fix: we manually wipe unused messages from memory, keeping the interface fast.

Problem

In long ChatGPT sessions the web app gradually slows down: scrolling stutters, typing lags, UI may freeze.
This happens because ChatGPT keeps all conversation turns not only in the DOM, but also in React in-memory arrays (props.messages).
Even deleted DOM nodes don’t help — old message objects remain referenced, including unfinished streaming drafts. Over time this leads to memory bloat and noticeable lag.

Solution

This userscript automatically trims old conversation turns both from the DOM and from React state, keeping only the most recent ones (default: 5).
By freeing memory in place, it prevents build-up of unused objects and keeps the interface smooth, even in very long chats.

Features

  • Keeps only the latest N messages (configurable)
  • Cleans both DOM and React props.messages arrays
  • Automatic periodic cleanup (interval configurable)
  • Manual “Clean now” button for one-click trim
  • Skips auto-clean when the tab is hidden (no background CPU waste)
  • Compact floating UI for settings
  • Works on both chat.openai.com and chatgpt.com
  • Runs fully locally, no data sent anywhere

Notes

  • This script only affects the local conversation window in your browser.
  • It does not delete or modify chat history stored in your OpenAI account.
  • After cleanup you still see the latest turns; old ones can be reloaded by refreshing the page.