🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

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.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Autore
Aleksey Maximov
Installazioni giornaliere
1
Installazioni totali
41
Valutazione
1 0 0
Versione
1.5
Creato il
26/07/2025
Aggiornato il
18/08/2025
Dimensione
7,65 KB
Licenza
MIT
Applica a

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.