# Reference Project Notes

## Scramble (zlwaterfield/scramble) ⭐ 1,647
- Uses `browserAPI` abstraction for Chrome/Firefox compat
- Content script listens for messages, calls background to do actual LLM calls
- **Key pattern:** `replaceSelectedText()` handles both:
  1. `TEXTAREA` / `INPUT` elements (uses selectionStart/End)
  2. Generic DOM selection (uses Range API)
- Context menu integration for triggering actions
- Good reference for: text replacement, context menu setup

## Proofly (onderceylan/proofly)
- Privacy-first: uses Chrome's built-in on-device AI (no API key needed)
- Good reference for: Manifest V3 structure, shadow DOM injection for UI

## Key Learnings for LexAI
1. **Always handle both textarea AND contenteditable** — different replacement logic needed
2. **Use shadow DOM for toolbar** — prevents host page CSS from breaking our UI
3. **Background as CORS proxy** — content scripts can't call external APIs directly
4. **Context menu = power user feature** — right-click → LexAI actions
5. **Debounce selection events** — users drag text slowly, don't fire on every pixel
