ChatGPT AutoCleaner v5

Bugfix & speed-up for ChatGPT: cleans the conversation chat window by trimming old messages from the Browser DOM. Keeps only the latest N turns visible, preventing lag and excessive DOM size on long sessions. Includes manual “Clean now” button and auto-clean toggle.

Author
Aleksey Maximov
Daily installs
0
Total installs
4
Ratings
0 0 0
Version
1.5
Created
2025-07-26
Updated
2025-08-18
Size
7.65 KB
License
MIT
Applies to

TL;DR

  • Everyone knows the pain: long ChatGPT sessions → the page gets slower and slower.
  • The UI is a heavy React app with lots of memory leaks, especially in background telemetry.
  • This script applies a safe quick fix: trims old chat messages from the DOM so the interface stays light and responsive.

Problem

In long single-thread chats, the web UI gradually lags: typing slows down, scrolling stutters, sometimes the tab even freezes.
One reason is that the DOM keeps growing with all conversation turns. Large DOM trees are expensive to render and update, especially when streaming tokens.

React also stores its own internal message arrays (including telemetry and unfinished drafts), which keep piling up. But at the moment, trimming those is risky — too many side effects.


Solution

This userscript automatically trims old conversation turns from the DOM only, keeping only the most recent ones (default: 5).
By keeping the DOM short and clean, it reduces rendering overhead and makes the interface smoother, even in long chats.


Features

  • Keeps only the latest N messages visible (configurable)
  • Automatic periodic cleanup (interval configurable)
  • Manual “Clean now” button for instant trim
  • Skips auto-clean when the tab is hidden (no background CPU churn)
  • Compact floating UI for settings
  • Works on both chat.openai.com and chatgpt.com
  • Fully local — no data sent anywhere

Notes

  • This script affects only the browser DOM view of the conversation.
  • It does not touch or delete chat history stored in your OpenAI account.
  • Old turns can always be reloaded by refreshing the page.
  • React’s internal memory still grows over time (messages + telemetry). That problem is more complex and not yet fixed safely here.