CLAUDE.md · diff

git:20250907.15d8811 to git:20250911.dfe9f79

47 added, 88 removed. Audit A to A.

# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
- AI Shortcuts (AI 任意门) is a Chrome browser extension that provides users with quick access to multiple AI websites including ChatGPT, DeepSeek, Gemini, Claude, and others. The extension supports both English and Chinese languages with automatic switching based on browser locale.
+ AI Shortcuts (AI 任意门) is a Chrome browser extension that enhances AI website usage efficiency. The extension allows users to:
+ 1. Access multiple AI websites in one tab using iframes
+ 2. Send queries to multiple AI sites simultaneously for comparison
+ 3. Use floating buttons and text selection shortcuts to query AI sites
+ 4. Configure preferred AI sites and customize the interface
+
## Architecture
### Core Components
- **Extension Structure:**
- - `manifest.json` - Chrome extension manifest (v3)
- - `background.js` - Service worker handling extension lifecycle and declarative net request rules
- - `popup/` - Extension popup interface for quick AI access
- - `options/` - Extension settings page for site configuration
- - `iframe/` - Side panel mode with multi-column AI site layout
- - `content-scripts/` - Injected scripts for various interaction modes
- - `config/` - Site configurations and global settings
-
- **Key Files:**
- - `config/defaultSites.js` - Default AI site configurations with iframe support flags
- - `config/config.js` - Global configuration including production/development console logging
- - `config/rules.json` - Declarative net request rules for iframe embedding
-
- ### AI Site Configuration
-
- Each AI site in `defaultSites.js` has these properties:
- - `name` - Display name
- - `url` - Site URL
- - `enabled` - Whether site is active
- - `supportUrlQuery` - Whether query can be appended to URL
- - `supportIframe` - Whether site works in iframe
- - `hidden` - Whether to hide from UI
- - `description` - Site description
-
- ### User Interaction Modes
-
- 1. **Selection Search** - Text selection triggers AI search dialog
- 2. **Float Button** - Persistent floating button on all pages
- 3. **Context Menu** - Right-click menu integration
- 4. **Search Engine Integration** - Button appears near search results
- 5. **Side Panel Mode** - Multi-column iframe layout for comparing AI responses
- 6. **Popup Mode** - Extension icon popup for quick access
-
- ### Content Script Injection
-
- The extension injects different scripts based on URL patterns:
- - AI sites get `iframe/inject.js` for iframe compatibility
- - All URLs get selection and float button functionality
- - Search engines get specialized integration scripts
-
- ### Storage and Configuration
-
- Uses `chrome.storage.sync` for:
- - Site configurations
- - User preferences (column layout, enabled features)
- - Button configuration settings
-
- ### Internationalization
-
- Supports English and Chinese through Chrome i18n API:
- - `_locales/en/messages.json`
- - `_locales/zh_CN/messages.json`
-
- ## Development Commands
-
- **No build system required** - This is a vanilla JavaScript Chrome extension.
-
- ### Testing the Extension
+ - **manifest.json**: Chrome extension manifest (Manifest V3)
+ - **background.js**: Service worker handling extension lifecycle and configuration updates
+ - **config/**: Configuration files for sites, rules, and base settings
+ - `siteHandlers.json`: AI site configurations with search handlers and iframe support
+ - `baseConfig.js`: Base configuration and default site definitions
+ - `rules.json`: Declarative net request rules
+ - **content-scripts/**: Injected scripts for various functionalities
+ - `float-button.js`: Floating button overlay on web pages
+ - `selection.js`: Text selection handling and popup display
+ - `search-engines.js`: Search engine integration (Google, Baidu, Bing)
+ - **iframe/**: Multi-AI comparison interface
+ - `iframe.html/js/css`: Main interface for displaying multiple AI sites
+ - `inject.js`: Script injected into AI sites for interaction
+ - **options/**: Extension options page for configuration
+ - **_locales/**: Internationalization support (English/Chinese)
- 1. Load unpacked extension in Chrome:
- - Open `chrome://extensions/`
- - Enable Developer mode
- - Click "Load unpacked" and select project directory
+ ### Key Features
- 2. Test different modes:
- - Visit any webpage to test float button and selection
- - Search on Google/Baidu to test search engine integration
- - Click extension icon to test popup
- - Open side panel to test iframe mode
+ 1. **Multi-AI Interface**: Uses iframes to embed multiple AI sites in one view
+ 2. **Site Handlers**: JavaScript functions that automate query submission on each AI site
+ 3. **Dynamic Configuration**: Remote config updates for adding new AI sites
+ 4. **Content Script Integration**: Floating buttons and text selection across all websites
+ 5. **Search Engine Integration**: Quick AI access buttons on search result pages
- ### Configuration Changes
+ ### AI Site Integration
- - Modify `config/defaultSites.js` to add/remove AI sites
- - Update `manifest.json` content_scripts matches for new AI sites
- - Set `CONFIG.IS_PRODUCTION = true` in `config/config.js` before release
+ Sites are configured in `config/siteHandlers.json` with properties:
+ - `supportIframe`: Whether site works in iframe
+ - `supportUrlQuery`: Whether site accepts query in URL
+ - `searchHandler`: JavaScript function to automate query submission
+ - `enabled`: Whether site is active
+ - `region`: Geographic region (China/US)
- ### iframe Compatibility
+ ### Key Files to Understand
- Sites that don't support iframe embedding require:
- - Adding URL to `config/rules.json` for header modification
- - Setting `supportIframe: false` in site configuration
- - Using tab-based opening instead of iframe
+ - `background.js:1-50`: Extension lifecycle and config management
+ - `iframe/iframe.js:1-50`: Main multi-AI interface logic
+ - `content-scripts/float-button.js:1-30`: Floating button creation
+ - `config/siteHandlers.json`: Complete AI site configurations
+ - `manifest.json`: Extension permissions and content script declarations
- ### Debugging
+ ## Development Notes
- Development mode logs include `[MultiAI]` prefix. Check:
- - Browser console on content pages
- - Extension service worker console
- - Extension popup/options page consoles
+ This is a Chrome extension project without traditional build tools like npm or webpack. Files are loaded directly as specified in manifest.json. The extension uses:
- ### Release Process
+ - Vanilla JavaScript (no frameworks)
+ - jQuery 3.7.1 (included in lib/)
+ - Chrome Extension APIs (storage, tabs, scripting, etc.)
+ - Dynamic script injection for AI site automation
- 1. Set `CONFIG.IS_PRODUCTION = true`
- 2. Update version in `manifest.json`
- 3. Test all interaction modes
- 4. Package extension for Chrome Web Store
+ No build, test, or lint commands are available - this is a standard Chrome extension that can be loaded directly in developer mode.