Skip to content

mahid797/chatgpt-virtualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

42 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ChatGPT Virtualizer

โšก A high-performance Chrome extension that virtualizes long ChatGPT conversations for blazing-fast performance

Chrome Extension Manifest V3 TypeScript License: MIT

ChatGPT Virtualizer is a Chrome Manifest V3 extension that virtualizes long ChatGPT conversations to maintain optimal browser performance. It intelligently manages DOM elements by mounting only visible conversation turns and replacing others with lightweight placeholders, reducing memory usage by up to 90% in long threads.

Key Benefits:

  • Eliminates browser slowdown on conversations with 50+ exchanges
  • Maintains full conversation context and accessibility
  • Zero data collection with complete offline functionality
  • Seamless integration with ChatGPT's native interface

Production Ready: Thoroughly tested with strict TypeScript, comprehensive error handling, and professional architecture.

โœจ Features

Core Virtualization

  • โšก Intelligent DOM Management โ€” Dynamically mounts/unmounts conversation turns based on visibility and user preferences
  • ๐Ÿ“Œ Smart Pinning System โ€” Pin important turns to prevent automatic collapse
  • ๐ŸŽฏ Tail Policy โ€” Automatically keeps the last N turns expanded for optimal UX
  • ๐Ÿงญ Bulk Operations โ€” Expand all, collapse above viewport, or collapse before specific turns

User Interface

  • ๐ŸŽ›๏ธ Per-Tab Control โ€” Enable/disable virtualization on individual ChatGPT tabs
  • ๐ŸŽจ Professional Design โ€” Clean, accessible UI with proper ARIA support and focus management
  • โŒจ๏ธ Keyboard Shortcuts โ€” Customizable hotkeys for common actions
  • โ“ Contextual Help โ€” Built-in help dialog with usage instructions

Technical Excellence

  • ๐Ÿ›ก๏ธ Privacy-First โ€” Zero analytics, no network requests, complete offline operation
  • โ™ฟ Accessibility โ€” Full keyboard navigation, screen reader support, motion preferences
  • ๐Ÿ”ง Developer Tools โ€” Debug mode and window.__cgptVirt API for power users
  • ๐Ÿ“Š Performance Metrics โ€” Real-time stats showing visible/total/pinned turn counts

๐Ÿ“ฆ Installation

Option 1: From Source (Recommended)

Prerequisites:

  • Chrome 120+ (Manifest V3 support)
  • Node.js โ‰ฅ 18.17
  • npm (included with Node.js)

Setup Instructions:

  1. Clone & build

    git clone https://github.com/mahid797/chatgpt-virtualizer.git
    cd chatgpt-virtualizer
    npm install
    npm run build
  2. Install Extension

    • Navigate to chrome://extensions
    • Enable Developer mode (toggle in top-right)
    • Click Load unpacked and select the dist/ folder
  3. Activate Extension

Option 2: Chrome Web Store

Coming Soon


๐ŸŽฎ Usage

Extension Popup

Access the control panel by clicking the extension icon in Chromeโ€™s toolbar.

Controls

  • Enable on this tab โ€” toggles virtualization for the current ChatGPT tab.
  • Keep last N turns โ€” sets how many recent turns remain expanded (enforced when you click Apply).
  • Help โ€” opens a contextual help dialog with shortcuts and feature explanations.
  • Stats โ€” shows โ€œCurrently visible / total โ€ข Pinnedโ€ when enabled on an active tab.

Bulk actions

  • Expand all turns โ€” makes all conversation turns visible (respects existing pins).
  • Collapse above viewport โ€” collapses turns that are above the first visible turn.
  • Collapse aboveโ€ฆ โ€” collapses everything before a specific turn:
    • #N format: use a 1-based turn index (e.g., #15 for turn 15)
    • data-turn-id format: use ChatGPTโ€™s internal turn identifier

Tip: All actions affect only the currently active ChatGPT tab.

In-page controls

Each turn has a small circular chevron button pinned to the right.

Action Behavior
Click Toggle expand/collapse for that turn
Shift+Click Pin the turn to keep it expanded
Alt+Click Clear the pin

Keyboard shortcuts

Shortcut Action
Ctrl/Cmd + Shift + 9 Expand all turns
Ctrl/Cmd + Shift + 8 Collapse above viewport

Customize at chrome://extensions/shortcuts.

๐ŸŽฏ How It Works

ChatGPT Virtualizer employs sophisticated DOM virtualization techniques to maintain optimal performance in long conversations:

Architecture Overview

The extension operates through three main components:

  1. State Manager โ€” Tracks each conversation turn's state (expanded/collapsed), user pins, and auto-intent preferences
  2. Virtualizer Engine โ€” Monitors DOM changes and applies tail policies to determine which turns should remain mounted
  3. Bulk Operations โ€” Provides high-level actions for managing multiple turns simultaneously

Virtualization Process

Turn Detection: The content script identifies ChatGPT turns using article[data-turn-id] selectors and creates a lightweight state management layer.

Smart Replacement: When a turn is collapsed:

  • Original DOM content is preserved in memory
  • Turn is replaced with a minimal placeholder (3-5 DOM nodes vs. 100+ original nodes)
  • Placeholder displays turn metadata (role, index) and maintains interaction capabilities

Tail Policy: Recent turns stay expanded based on your "Keep last N" setting, while older turns collapse automatically unless pinned.

Performance Impact

Scenario Before Virtualization After Virtualization Improvement
50-turn conversation ~5000 DOM nodes ~500 DOM nodes 90% reduction
100-turn conversation ~10000 DOM nodes ~800 DOM nodes 92% reduction
Memory usage High (slowdown) Minimal (smooth) Significant

The extension maintains conversation context and accessibility while dramatically reducing browser resource consumption.


โš™๏ธ Settings

Access settings through the extension popup (click the toolbar icon):

Setting Description
Enable on this tab Turn virtualization on/off for the current ChatGPT conversation
Keep last N turns How many recent exchanges always stay visible (default: 3)

Settings are saved automatically. Per-tab enablement is session-scoped and independent for each tab; Keep last N is a global setting.


โ™ฟ Accessibility

  • ARIA states โ€” Chevron button uses aria-expanded to reflect turn state.
  • Focus management โ€” Keyboard navigation with visible focus rings across buttons, fields, and the toggle.
  • Motion respect โ€” Honors prefers-reduced-motion for animations.
  • Screen readers โ€” Proper labeling and state announcements.

๐Ÿ”’ Permissions & Privacy

Required Permissions

  • storage โ€” For local settings persistence
  • tabs โ€” To locate and message the active ChatGPT tab
  • Host permissions: https://chat.openai.com/*, https://chatgpt.com/*

Privacy Commitment

  • โœ… No analytics or telemetry
  • โœ… No remote calls or data collection
  • โœ… All processing happens locally in your browser
  • โœ… Open source for full transparency

๐Ÿ’ป Compatibility

  • Chrome: Version 120 or newer
  • Chromium-based browsers: Edge, Brave, Opera (version 120+)
  • Websites: Works on both chat.openai.com and chatgpt.com

๐Ÿ”ง Troubleshooting

Common issues

Extension installed but no chevron buttons visible

  • Ensure youโ€™re on chat.openai.com or chatgpt.com.
  • Verify the extension is enabled on this tab via the popup.
  • Refresh the page after enabling for the first time.
  • Check that you have at least one conversation turn visible.

Bulk actions donโ€™t work

  • Confirm virtualization is enabled on the current tab.
  • Ensure youโ€™re on an active ChatGPT conversation page.
  • Check the browser console for errors (F12 โ†’ Console).

Collapsed turns donโ€™t expand when clicked

  • Click the circular chevron button (not the placeholder text).
  • Try Shift+Click to pin first, then click normally.
  • Verify the page hasnโ€™t navigated away from ChatGPT.

Settings changes not taking effect

  • โ€œKeep last Nโ€ is enforced when you click Apply.
  • If issues persist, try disabling and re-enabling the extension.

Performance issues persist despite virtualization

  • Check if debug mode is accidentally enabled (adds overhead).
  • Verify that most older turns are collapsed.
  • Lower the Keep recent value for very long conversations.

Console shows runtime.lastError warnings

  • MV3 service workers can sleep; reopen the ChatGPT tab and try again. The popup handles this gracefully.

Changes not picked up after rebuild

  • Click Reload on the extension in chrome://extensions/ after building.

Debug information

When debug mode is enabled:

  • Console logging shows virtualization decisions.
  • Visual indicators highlight placeholder boundaries.
  • The window.__cgptVirt API becomes available for inspection.

Getting help

  1. Open the built-in Help dialog in the popup.
  2. Review this troubleshooting section.
  3. Inspect the console for errors.
  4. For persistent issues, see CONTRIBUTING.md for bug-reporting guidelines.

๐Ÿง‘โ€๐Ÿ’ป Contributing

We welcome contributions from developers! This is an open-source project built with TypeScript and modern Chrome extension standards.

For Contributors: See CONTRIBUTING.md for complete development setup, architecture details, and coding guidelines.

Privacy Commitment: All contributions must maintain our zero-analytics, offline-first approach. No telemetry or network requests allowed.


๐Ÿ“„ License & Credits

ChatGPT Virtualizer is licensed under the MIT License โ€” see the LICENSE file for details.

Copyright (c) 2025 ChatGPT Virtualizer

Acknowledgments

Built with modern web standards and Chrome extension best practices. No third-party dependencies in production build.


โญ Star this repo if it helps you keep your ChatGPT conversations snappy! โญ

About

A browser extension for enhancing ChatGPT's interface and functionality.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published