A browser extension that helps you create AI-powered flashcards from highlighted text on any webpage. Uses OpenRouter API to generate smart, dictionary-style definitions.
- Context Menu Integration: Right-click any highlighted text to create a flashcard
- AI-Powered Definitions: Uses OpenRouter AI models (Claude, GPT, Llama, etc.) to generate clear, educational definitions
- Local Storage: All flashcards stored locally in your browser
- Anki Export: Export flashcards to Anki-compatible format for spaced repetition learning
- Customizable Prompts: Choose between default dictionary-style prompts or create your own
- Model Selection: Support for multiple AI models with different capabilities and costs
- Search & Sort: Easily find and organize your flashcards
- Edit & Delete: Full management of your flashcard collection
- Download or clone this repository
- Open Chrome/Edge and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in top-right corner)
- Click "Load unpacked"
- Select the
highlight-flashcardfolder - The extension icon should appear in your toolbar
- Download or clone this repository
- Open Firefox and navigate to
about:debugging#/runtime/this-firefox - Click "Load Temporary Add-on"
- Select the
manifest.jsonfile from thehighlight-flashcardfolder - The extension will be loaded temporarily (will persist until Firefox restart)
Note: For permanent installation in Firefox, the extension needs to be signed. See Firefox Add-on Distribution.
- Visit OpenRouter
- Sign up for an account
- Navigate to API Keys
- Create a new API key (starts with
sk-or-) - Copy the API key
- Click the extension icon in your toolbar
- Click the "Settings" button (βοΈ) or right-click the extension icon and select "Options"
- Paste your OpenRouter API key
- (Optional) Select your preferred AI model
- (Optional) Customize the prompt
- Click "Test Connection" to verify your setup
- Click "Save Settings"
- Highlight text on any webpage
- Right-click the selected text
- Select "Create Flashcard" from the context menu
- Wait a few seconds for the AI to generate a definition
- You'll see a notification when the flashcard is created
- Click the extension icon in your toolbar
- Browse your flashcard collection
- Use the search bar to find specific flashcards
- Sort by newest, oldest, or alphabetically
- Edit: Click the βοΈ icon on any flashcard to edit the word or definition
- Delete: Click the ποΈ icon to delete a flashcard
- Search: Use the search bar to filter flashcards by word, definition, or source URL
- Sort: Use the sort dropdown to organize your flashcards
You can export your flashcards to Anki format for spaced repetition learning:
- Click the extension icon to open your flashcard collection
- (Optional) Use search or sort to filter which cards you want to export
- Click the "π₯ Export to Anki" button in the toolbar
- A text file will be downloaded (e.g.,
highlight-flashcards-2025-11-08.txt) - Open Anki and go to File β Import
- Select the downloaded file
- Configure import settings:
- Field separator: Tab
- Allow HTML in fields: β Checked
- Field mapping: Field 1 β Front, Field 2 β Back
- Deck: Choose or create a deck (default: "Highlight Flashcards")
- Note type: Basic
- Click Import
Note: The exported file includes helpful instructions in the header comments. Each flashcard includes the word/phrase on the front and the AI-generated definition plus source URL on the back.
The extension supports multiple AI models through OpenRouter:
| Model | Provider | Best For | Cost |
|---|---|---|---|
| Claude 3.5 Sonnet | Anthropic | Recommended - Best quality definitions | Medium |
| Claude 3 Haiku | Anthropic | Fast responses, lower cost | Low |
| GPT-4 Turbo | OpenAI | High quality, detailed explanations | High |
| GPT-3.5 Turbo | OpenAI | Fast and affordable | Low |
| Grok Beta | xAI | Fast responses, good quality | Low-Medium |
| Llama 3.1 8B | Meta | Open source, very affordable | Very Low |
| Gemini Pro | Good balance of quality and cost | Medium |
Note: Different models have different pricing. Check OpenRouter pricing for current rates.
You can also use any other model available on OpenRouter by selecting "Enter custom model ID" in the settings:
- Go to OpenRouter Models
- Find the model you want to use
- Copy the model ID (e.g.,
anthropic/claude-3-opus,openai/gpt-4) - In extension settings, select "Enter custom model ID"
- Paste the model ID
- Test the connection to verify it works
This allows you to use newly released models without waiting for an extension update.
The extension uses this default prompt for generating definitions:
You are a helpful English dictionary assistant. Provide a clear, concise definition for the following word or phrase. Include:
1. Part of speech
2. Definition (one or two sentences)
3. Example sentence using the word in context
Format your response in a clear, easy-to-understand manner suitable for a flashcard. Use markdown for formatting.
You can customize the prompt to suit your needs:
Language Learning:
Translate the following word to Spanish and provide:
1. Spanish translation
2. Part of speech
3. Example sentence in Spanish
4. Pronunciation guide
Word: {word}
Technical Terms:
Explain the following technical term as if teaching a beginner:
1. Simple definition
2. Real-world analogy
3. Common use case
4. Related concepts
Term: {word}
Historical Context:
Provide historical context for: {word}
Include:
1. Definition
2. Historical origin
3. How usage has evolved
4. Modern significance
highlight-flashcard/
βββ manifest.json # Extension configuration
βββ background/
β βββ background.js # Service worker (context menu, orchestration)
β βββ api.js # OpenRouter API client
βββ lib/
β βββ storage.js # Storage abstraction layer
βββ ui/
β βββ flashcards.html # Main popup (flashcard viewer)
β βββ flashcards.js # Flashcard viewer logic
β βββ flashcards.css # Flashcard viewer styles
β βββ settings.html # Settings page
β βββ settings.js # Settings page logic
β βββ settings.css # Settings page styles
βββ icons/
β βββ icon16.png # Extension icon (16x16)
β βββ icon48.png # Extension icon (48x48)
β βββ icon128.png # Extension icon (128x128)
βββ specs/ # Technical specifications
βββ README.md # This file
- Node.js (optional, for development tools)
- Chrome or Firefox browser
- OpenRouter API key
- Make changes to the code
- Go to
chrome://extensions/(orabout:debuggingin Firefox) - Click "Reload" on the extension
- Test your changes
-
Background Service Worker:
- Chrome:
chrome://extensions/β Click "Inspect views: service worker" - Firefox:
about:debuggingβ Click "Inspect" next to the extension
- Chrome:
-
Popup/Settings Pages:
- Right-click the popup or settings page
- Select "Inspect"
-
Console Logs:
- All logs from
background.jsappear in the service worker console - All logs from UI pages appear in the page's dev tools console
- All logs from
- Maximum Storage: ~5MB (Chrome local storage limit)
- Estimated Capacity: 5,000-10,000 flashcards (depending on definition length)
- Warning Threshold: The extension will warn when storage exceeds 4MB
- Local Storage: All flashcards are stored locally in your browser
- No Tracking: The extension does not track or collect any user data
- API Key Security: Your OpenRouter API key is stored locally and never shared
- HTTPS Only: All API requests use HTTPS encryption
- Go to Settings and enter your OpenRouter API key
- Make sure the key starts with
sk-or- - Click "Test Connection" to verify
- Check your internet connection
- Verify your API key is valid
- Check your OpenRouter account has credits
- Try a different AI model
- Check browser storage is not full
- Try clearing old flashcards
- Check browser console for errors
- Make sure text is selected
- Try reloading the extension
- Check extension permissions in browser settings
- Spaced repetition algorithm for studying
- Export flashcards to CSV/Anki format
- Import flashcards from other sources
- Multiple language support
- Flashcard categories/tags
- Study mode with quizzes
- Sync across devices
- Offline mode with cached definitions
- Browser action badge with flashcard count
- Keyboard shortcuts for quick access
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project follows a spec-driven development approach. See the specs/ directory for detailed specifications:
MIT License - see LICENSE file for details
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check existing issues for solutions
- Review the troubleshooting section above
- Uses OpenRouter for AI model access
- Built with vanilla JavaScript (no frameworks)
- Icons: Simple custom design (feel free to replace with your own)
Enjoy building your flashcard collection! π