This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
AI Chat Navigator is a browser extension that adds navigation sidebars to AI chat platforms (Gemini, ChatGPT, Claude, AI Studio). The extension uses a sophisticated Provider Pattern to abstract platform-specific DOM interactions while maintaining a single codebase.
The extension uses a Provider Pattern with Factory for multi-platform support:
- Base Provider:
AIProviderclass defines interface (getSelectors(),getLayoutConfig(),extractTextContent()) - Concrete Providers: Platform-specific implementations (GeminiProvider, ChatGPTProvider, ClaudeProvider, AIStudioProvider)
- Provider Factory:
ProviderFactoryauto-detects current platform and returns appropriate provider
manifest.json- Extension configuration and content script injection rulesproviders.js- Provider pattern implementation (Strategy layer)content.js- Main application logic (~700 lines, handles UI and event management)styles.css- Navigation sidebar styling with smooth transitions
- In-memory only: No persistent storage, state resets on page reload
- Session-scoped:
sessionQueriesarray stores current chat messages - Live validation:
validateSessionQueries()removes stale DOM references
# Load unpacked extension in Chrome:
# 1. Navigate to chrome://extensions
# 2. Enable Developer mode
# 3. Click "Load unpacked"
# 4. Select project directory- No build process required - vanilla JavaScript
- Reload extension in chrome://extensions after code changes
- Test across all supported platforms: Gemini, ChatGPT, Claude, AI Studio
- MutationObserver: Watches DOM changes with 1000ms debounce
- Input Listeners: Detects form submissions with 200ms delay for immediate updates
- Page Navigation: Handles SPA routing with custom history.pushState wrapper
Each provider defines platform-specific selectors:
- queries: User message elements
- responses: AI response elements
- inputField: Text input areas
- submitButton: Send buttons
- chatContainer: Main chat container
- Selector Brittleness: Platform UI changes can break selectors - monitor target sites
- Provider Extension: Add new AI platforms by creating new provider class
- Input Detection: Recent addition for immediate sidebar updates on message submission
- Session Scope: Single page view lifecycle
- Data Validation: Continuous verification against live DOM to prevent stale references
- Memory Management: Automatic cleanup on page navigation
When AI platforms update their UI, selectors in providers.js may need updates. Check browser console for "AI Navigator" logs to diagnose issues.
To add a new AI chat platform:
- Create new provider class extending
AIProvider - Implement required methods with platform-specific selectors
- Add URL patterns to manifest.json matches array
- Register provider in ProviderFactory
- Uses debouncing for DOM observation (1000ms) and search (200ms)
- Efficient DOM querying with fallback selectors
- Memory cleanup through session validation