A Chrome extension that helps users learn new languages by translating words on web pages in real-time. The extension works with a Python Flask backend that provides intelligent word translation based on the user's learning level.
- Real-time Translation: Translates words on any webpage based on user's learning level
- Interactive Learning: Hover tooltips show meaning and pronunciation
- Customizable Settings: Choose target language and learning level
- Non-intrusive: Preserves original page layout and styling
- Smart Word Filtering: Focuses on meaningful vocabulary, filters out common words
- Dynamic Content Support: Handles dynamically loaded content
- Learning Statistics: Track how many words you've learned
SpurHacked consists of two main components:
-
Chrome Extension (Frontend)
- Extracts text from web pages
- Sends text to backend for translation
- Replaces words with translations
- Shows interactive tooltips
-
Python Flask Backend (API)
- Processes text and extracts meaningful words
- Provides translations based on learning level
- Returns structured translation data
1. User enables translation in extension popup
2. Content script extracts text from webpage
3. Text is sent to Flask backend via POST /translate
4. Backend filters words and returns translations
5. Content script replaces words with translated versions
6. Hover events show tooltips with details
- Content script walks through all text nodes in the document
- Filters out script, style, and already processed elements
- Extracts clean text content for processing
- Receives text, learning level, and target language
- Uses regex to extract individual words
- Filters out common English words (the, a, and, etc.)
- Matches words against translation database
- Returns structured translation data
- Creates DOM elements for translated words
- Preserves original capitalization
- Adds hover event listeners for tooltips
- Maintains page layout and styling
- Shows on hover over translated words
- Displays: original word → translation
- Includes meaning and pronunciation
- Positioned dynamically based on word location
spurHacked/
├── backend/ # Python Flask backend
│ ├── app.py # Main Flask application with translation logic
│ ├── requirements.txt # Python dependencies
│ └── README.md # Backend documentation
├── extension/ # Chrome extension
│ ├── manifest.json # Extension manifest (Manifest V3)
│ ├── content.js # Content script for webpage interaction
│ ├── popup.html # Extension popup interface
│ ├── popup.js # Popup functionality and settings
│ ├── background.js # Background service worker
│ ├── styles.css # Extension styles with responsive design
│ └── icon*.png # Extension icons (placeholders)
├── venv/ # Python virtual environment
├── setup.sh # Automated setup script
├── manual_setup.sh # Manual setup instructions
├── test_backend.py # Backend testing script
├── INSTALLATION.md # Detailed installation guide
├── PROJECT_SUMMARY.md # Complete project documentation
└── README.md # This file
Translates text based on learning level and target language.
Request Body:
{
"text": "Hello world, this is a beautiful morning.",
"level": "beginner",
"targetLanguage": "fr"
}Response:
{
"translations": [
{
"original": "hello",
"translated": "bonjour",
"meaning": "hello",
"pronunciation": "bohn-ZHOOR"
},
{
"original": "world",
"translated": "monde",
"meaning": "world",
"pronunciation": "mohnd"
}
],
"total_words_found": 8,
"translations_provided": 2
}Health check endpoint for connection testing.
- Text Extraction: Safely extracts text from web pages using TreeWalker
- Word Replacement: Replaces words with translations using DOM manipulation
- Tooltip System: Creates interactive tooltips for translated words
- DOM Observation: Handles dynamically loaded content with MutationObserver
- Error Handling: Graceful error handling and fallbacks
- Storage API: Saves user settings and statistics
- Message Passing: Communication between popup and content script
- Background Script: Handles extension lifecycle and tab updates
- Modern UI: Clean, gradient-based popup interface
- Responsive Design: Works on different screen sizes
- Accessibility: Supports dark mode and high contrast
- Smooth Animations: Fade-in effects for translated words
- User clicks extension icon
- Configures language and learning level
- Enables translation
- Navigates to any webpage
- Words are automatically translated
- Hover over translated words for details
-
Clone the repository:
git clone <repository-url> cd spurHacked
-
Run the setup script:
./setup.sh
This will:
- Check for Python and pip installation
- Create virtual environment
- Install backend dependencies
- Start the backend server
-
Navigate to the backend directory:
cd backend -
Create and activate virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Start the server:
python app.py
The API will be available at
http://localhost:5001
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in top right)
- Click "Load unpacked" and select the
extensiondirectory - Verify installation - the extension should appear in your toolbar
# Run the test script
python test_backend.py- Load the extension in Chrome
- Navigate to a news website or blog
- Enable translation in the popup
- Verify words are translated
- Hover over translated words to see tooltips
- French (fr): Beginner, Intermediate, Advanced levels
- Spanish (es): Beginner, Intermediate, Advanced levels
- German (de): Beginner, Intermediate, Advanced levels
- Beginner: Basic vocabulary (hello, world, good, etc.)
- Intermediate: More complex words (beautiful, important, difficult, etc.)
- Advanced: Sophisticated vocabulary (sophisticated, revolutionary, philosophical, etc.)
- Real Translation API: Integrate with Google Translate, DeepL, or similar
- More Languages: Add support for additional languages
- Learning Analytics: Track progress and provide insights
- Spaced Repetition: Implement learning algorithms
- Audio Pronunciation: Add audio playback for pronunciations
- Vocabulary Lists: Save and review learned words
- Gamification: Add points, badges, and challenges
- Database Integration: Store user progress and preferences
- User Authentication: Multi-user support
- Cloud Deployment: Deploy backend to cloud services
- Mobile Support: Create mobile app version
- Offline Mode: Cache translations for offline use
- Mock Data: Currently uses mock translation data
- Icon Files: Placeholder icons need to be replaced with actual PNG files
- Limited Languages: Only supports French, Spanish, and German
- Local Backend: Requires local Python server (not cloud-hosted)
- Chrome Only: Extension only works in Chrome/Chromium browsers
- Modular Design: Clean separation of concerns
- Error Handling: Comprehensive error handling throughout
- Documentation: Well-documented code with comments
- Standards: Follows Chrome extension Manifest V3 standards
- Local Backend: Runs on localhost for development
- CORS Configuration: Properly configured for extension communication
- No External Data: No data sent to external servers (except backend)
- Permission Minimal: Only requests necessary permissions
SpurHacked is a fully functional language learning Chrome extension with a robust Python backend. It provides an innovative way to learn languages by translating words in real-time while browsing the web. The project demonstrates modern web development practices, Chrome extension development, and API design.
The extension is ready for use and can be easily extended with real translation APIs, additional languages, and enhanced learning features.
This project is for educational purposes. Please respect the terms of use for any translation APIs you integrate.