ChatGPT Virtual Scroll

Optimizes long ChatGPT threads by virtualizing old conversation turns

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
作者
9ghtX
1日のインストール数
1
累計インストール数
6
評価
0 0 0
バージョン
2.2.0
作成日
2026/03/19
更新日
2026/03/19
大きさ
12.6KB
ライセンス
MIT
対象サイト

ChatGPT Virtual Scroll

A userscript for long ChatGPT conversations that reduces DOM load by virtualizing old conversation turns.

Instead of keeping the entire chat rendered at once, the script keeps only a small active window of recent turns in the DOM, removes older turns above the viewport, and restores them when you scroll back up.

This makes large chats more responsive and helps reduce lag in long threads.

Features

  • Virtualizes old conversation turns in long chats
  • Keeps only a small active window of recent turns in the DOM
  • Restores older turns when scrolling upward
  • Preserves viewport position with anchor-based compensation
  • Works on:

How it works

The script:

  1. Detects the conversation scroll container
  2. Keeps a limited number of conversation-turn sections in the DOM
  3. Removes older turns above the active window
  4. Stores removed turns in an in-memory buffer
  5. Restores them when the user scrolls upward
  6. Uses anchor-based compensation to avoid visible jumps during restore/prune operations

This is designed for very long chats where rendering the full conversation causes performance issues.

Current configuration

The script is currently tuned to keep a very small live window:

  • MAX_TURNS = 6
  • MIN_TURNS = 4
  • PRUNE_BATCH = 1
  • RESTORE_BATCH = 1

This means the script tries to keep roughly the last 4 conversation turns active, while still preserving stable scrolling behavior.

Installation

Option 1: Install directly from GitHub

Open the raw .user.js file in a browser with a userscript manager installed, such as Tampermonkey.

Example userscript managers:

  • Tampermonkey
  • Violentmonkey
  • Greasemonkey

Raw install URL:

https://raw.githubusercontent.com/9ghtX/ChatGPT-Optimizer/main/chatgpt-virtual-scroll.user.js

Option 2: Manual installation

  1. Install a userscript manager extension
  2. Copy the contents of chatgpt-virtual-scroll.user.js
  3. Create a new userscript
  4. Paste the code
  5. Save it

Updating

If installed from the raw GitHub URL and the metadata block contains @updateURL and @downloadURL, your userscript manager should be able to detect updates automatically.

Recommended metadata block

// ==UserScript==
// @name         ChatGPT Virtual Scroll
// @namespace    https://github.com/9ghtX/ChatGPT-Optimizer
// @version      2.2.0
// @description  Optimizes long ChatGPT threads by virtualizing old conversation turns
// @author       9ghtX
// @match        https://chatgpt.com/*
// @match        https://chat.openai.com/*
// @grant        none
// @downloadURL  https://raw.githubusercontent.com/9ghtX/ChatGPT-Optimizer/main/chatgpt-virtual-scroll.user.js
// @updateURL    https://raw.githubusercontent.com/9ghtX/ChatGPT-Optimizer/main/chatgpt-virtual-scroll.user.js
// ==/UserScript==

Known limitations

  • The script depends on ChatGPT’s current DOM structure
  • If OpenAI changes container structure, class behavior, or data-testid usage, the script may stop working correctly
  • Very aggressive settings can cause unstable scrolling if the active window is too small
  • The script currently works entirely in memory; removed turns are not serialized or persisted
  • Behavior may differ between standard chats, project chats, and grouped chats if their layout differs

Debugging

If needed, enable debug logs in the script:

const DEBUG = true;

This will print internal prune/restore events to the browser console.

For normal use or public release, it is recommended to keep:

const DEBUG = false;

Configuration

The main tuning parameters are:

const MAX_TURNS = 6;
const MIN_TURNS = 4;
const PRUNE_BATCH = 1;
const RESTORE_BATCH = 1;

const RESTORE_ANCHOR_INDEX = 1;
const PRUNE_ANCHOR_INDEX = 3;

Meaning

  • MAX_TURNS: maximum number of turns allowed before pruning starts
  • MIN_TURNS: target minimum number of turns to keep after pruning
  • PRUNE_BATCH: how many old turns to remove at once
  • RESTORE_BATCH: how many buffered turns to restore at once
  • RESTORE_ANCHOR_INDEX: restore when the anchor gets close to the top of the active window
  • PRUNE_ANCHOR_INDEX: prune when the anchor moves deep enough into the active window

Why this exists

ChatGPT can become sluggish in very long threads because the page keeps too many rendered conversation elements alive at the same time.

This script is an attempt to reduce that cost without fully breaking normal scrolling behavior.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Issues and suggestions are welcome.

If you find a broken layout case, include:

  • the ChatGPT page type where it happened
  • a DOM snippet if possible
  • reproduction steps
  • current script settings
  • console logs if DEBUG is enabled