Instruction file imported from 3b3ziz/not-to-disappear-extension (
.cursor/rules/extension-development.mdc). Copyright stays with the author.
Chrome Extension Development Guidelines
Content Script Patterns
- DOM Observation: Use MutationObserver with debouncing for ChatGPT's dynamic content
- Streaming Detection: Only check for ChatGPT's "Stop generating" button - avoid text-based heuristics
- Button Injection: Wait for action buttons container with proper flex layout detection
- PostMessage Bridge: Secure communication between web app and extension
Storage Patterns
- Local Only: Use
chrome.storage.localfor all data persistence - No External APIs: Never send data to external servers
- User Privacy: All data stays on user's device
Performance Considerations
- Debouncing: Use timeouts to prevent excessive DOM processing
- Efficient Selectors: Use specific selectors to avoid false positives
- Minimal DOM Queries: Cache results and avoid repeated queries
Error Handling
- Graceful Degradation: Extension should work even if some features fail
- User Feedback: Provide clear error messages and success indicators
- Console Logging: Use consistent logging patterns for debugging
Security
- No Hardcoded Secrets: All API keys and URLs should be empty for local-only operation
- Content Security: Sanitize user input and escape HTML
- PostMessage Validation: Only accept messages from same origin