A powerful Chrome extension that uses AI to instantly analyze the emotional tone of any text on the web. Powered by a fine-tuned DistilBERT model, it detects positive, negative, or neutral/mixed sentiments with confidence scoring.
- Instant Analysis: Right-click any selected text and analyze its sentiment in seconds
- AI-Powered: Uses a fine-tuned DistilBERT model optimized for sentiment classification
- Confidence Scoring: Displays confidence levels with visual progress bars
- Clean UI: Modern, animated interface with color-coded sentiment indicators
- Privacy-Focused: Text is only processed when you explicitly request it
- Fast Response: Optimized API hosted on Hugging Face Spaces
- Select any text on a webpage
- Right-click and choose "Analyze Sentiment"
- View instant results with sentiment classification and confidence score
- Chrome Manifest V3
- Vanilla JavaScript
- CSS3 with smooth animations
- Chrome Extension APIs
- Framework: Flask
- Model: Fine-tuned DistilBERT (3-class sentiment classifier)
- ML Library: Transformers (Hugging Face)
- Deployment: Hugging Face Spaces
- Server: Gunicorn
-
Clone the repository:
git clone https://github.com/Destroyer795/SA-Web-Extension.git cd SA-Web-Extension -
Load in Chrome:
- Open Chrome and navigate to
chrome://extensions/ - Enable Developer mode (toggle in top-right)
- Click Load unpacked
- Select the
extensionfolder from this project
- Open Chrome and navigate to
-
Start using:
- Select any text on a webpage
- Right-click and choose "Analyze Sentiment"
-
Install dependencies:
pip install -r requirements.txt
-
Run the Flask server:
python app.py
-
Update API endpoint (if running locally):
- Open
extension/popup.js - Change
API_URLtohttp://localhost:7860/predict
- Open
- Model Type: DistilBERT for Sequence Classification
- Classes: Positive, Negative, Neutral
- Confidence Threshold: 70% (scores below are marked as "Neutral / Mixed")
- Location:
./sentiment_analyzer_pro/
Analyzes sentiment of provided text.
Request:
{
"text": "This is an amazing product!"
}Response:
{
"sentiment": "Positive",
"score": 0.9542,
"confidence_flag": "High"
}Health check endpoint.
.
├── extension/ # Chrome extension files
│ ├── manifest.json # Extension configuration
│ ├── popup.html # Popup UI
│ ├── popup.js # Popup logic
│ ├── popup.css # Popup styles
│ └── background.js # Background service worker
├── sentiment_analyzer_pro/ # Fine-tuned DistilBERT model
│ ├── model.safetensors
│ ├── config.json
│ ├── tokenizer.json
│ └── ...
├── app.py # Flask API server
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
└── README.md
The model returns a label and confidence score:
- High Confidence (≥70%): Returns the predicted sentiment (Positive/Negative)
- Low Confidence (<70%): Returns "Neutral / Mixed" to handle ambiguous or sarcastic text
This approach reduces false positives for edge cases like sarcasm or mixed emotions.
The API is currently deployed at:
https://destroyer795-sentiment-analyzer-extension.hf.space/
To deploy your own:
- Create a Hugging Face Space
- Upload the project files
- Update the
API_URLinextension/popup.js
Build and run using Docker:
docker build -t sentiment-analyzer .
docker run -p 7860:7860 sentiment-analyzerContributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
This project is licensed under the MIT License - see the LICENSE file for details.
- Hugging Face for the Transformers library and hosting platform
- DistilBERT model architecture by Hugging Face
- Chrome Extension APIs documentation
- Developer: Destroyer795
- Hugging Face Space: Sentiment-Analyzer-Extension