Project Overview
Technical Architecture (Manifest V3)
1. Service Worker & Context Menus
2. Secure API Key Management
3. DOM Injection and Replacement
Key Features
- Context Menu Integration: Trigger rewrites directly from any webpage input field without copying and pasting.
- 17+ Tone Options: Built-in system instructions that guide the Gemini model to output specific tones.
- Custom Prompts: Users can write their own templates (e.g., "Translate to German and keep it informal").
- Local Analytics: Tracks character processing counts and favorite modes stored entirely in chrome.storage.local.
- Keyboard Shortcuts: Custom hotkeys to repeat the last rewrite action.
Challenges and Solutions
- Ephemeral Service Workers: Manifest V3 service workers terminate after a period of inactivity. Any in-memory variables (like ongoing API calls or request logs) are lost. To resolve this, all persistent data (user settings, custom modes) is saved in chrome.storage.sync, and the service worker is designed to be completely stateless.
- Contenteditable Support: Standard text inputs (<input> and <textarea>) are easy to modify. However, rich text editors (like Gmail or Google Docs) use contenteditable divs and iframe structures. The content script utilizes Selection and Range APIs to insert text at the cursor position without breaking the editor's internal DOM.