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.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
Aleksey Maximov
日安装量
0
总安装量
41
评分
1 0 0
版本
1.5
创建于
2025-07-26
更新于
2025-08-18
大小
7.7 KB
许可证
MIT
适用于

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.