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.
当前为
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.
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.
props.messages arrayschat.openai.com and chatgpt.com