A Chrome extension that helps you clean up your Gmail inbox by deleting emails based on custom keywords. Perfect for removing promotional emails, newsletters, and other unwanted messages in bulk.
- Gmail OAuth Integration: Secure authentication with Google's OAuth2
- Custom Keyword Search: Find and delete emails containing specific keywords
- Batch Operations: Efficiently process large numbers of emails
- Email Preview: Preview email subjects before deletion for safety
- Real-time Progress: Live updates during deletion process
- Token Management: Automatic token validation and refresh
- Mozilla Firefox browser
- A Google account with Gmail access
- Google Cloud Console project with Gmail API enabled
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API:
- Navigate to "APIs & Services" > "Library"
- Search for "Gmail API" and enable it
- Create OAuth2 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Web application"
- Add your extension ID to authorized origins
- Update the
CLIENT_IDinbackground.jswith your credentials
- Clone or download this repository
- Open Firefox and navigate to
Firefox://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked" and select the extension directory
- The MailPilot icon should appear in your Chrome toolbar
Update the CLIENT_ID constant in background.js:
const CLIENT_ID = "your-client-id-here.apps.googleusercontent.com";Clustify/
├── manifest.json # Extension configuration
├── background.js # Background script handling OAuth
├── popup.html # Extension popup UI
├── popup.js # Popup logic and Gmail API calls
├── style.css # UI styling
└── README.md # This file
WhatsApp.Video.2025-09-06.at.1.16.53.PM.mp4
- Click the MailPilot extension icon in Chrome
- Click "Connect Gmail" button
- Authorize the extension to access your Gmail account
- Once connected, the interface will enable all features
- Enter a keyword in the "Custom Keyword Search" field
- Click "Count by Keyword" to see how many emails match
- Click "Delete by Keyword" to preview and delete matching emails
- Confirm deletion in the preview modal
- Gmail Profile:
GET /gmail/v1/users/me/profile - Message Search:
GET /gmail/v1/users/me/messages - Message Details:
GET /gmail/v1/users/me/messages/{id} - Batch Delete:
POST /gmail/v1/users/me/messages/batchDelete
- Pagination Handling: Automatically fetches all pages of search results
- Batch Processing: Deletes up to 1,000+ emails per API call
- Error Handling: Comprehensive error handling with user feedback
- Token Management: Automatic token storage and validation
- Preview Before Delete: Always shows email subjects before deletion
- User Confirmation: Requires explicit confirmation before deletion
- Progress Updates: Real-time feedback during operations
- Error Recovery: Handles API errors gracefully
The extension requires the following permissions:
identity: For Google OAuth authenticationstorage: For storing authentication tokenshttps://gmail.googleapis.com/*: Gmail API accesshttps://www.googleapis.com/*: Google APIs accesshttps://accounts.google.com/*: Google authentication
"Token expired" error:
- Click "Connect Gmail" again to re-authenticate
"No emails found" when you expect results:
- Check your keyword spelling
- Try broader search terms
- Ensure you're searching in the correct Gmail account
Extension not loading:
- Check that all files are in the correct directory
- Verify manifest.json syntax
- Check Chrome's extension error logs
The extension provides detailed console logging. To view:
- Right-click the extension popup
- Select "Inspect"
- Check the Console tab for detailed logs
- Background Script (
background.js): Handles OAuth flow and token management - Popup Script (
popup.js): Main application logic and Gmail API interactions - UI (
popup.html): Extension interface
- Add UI elements to
popup.html - Add event listeners in
popup.js - Implement Gmail API calls using the existing pattern
- Update permissions in
manifest.jsonif needed
This project is open source. Please ensure you comply with Google's API usage policies and terms of service.
This extension permanently deletes emails from your Gmail account. Always preview emails before deletion and use at your own risk. The developers are not responsible for any data loss.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section above
- Review Firefox extension developer documentation
- Check Gmail API documentation
- Open an issue in the project repository
Note: Remember to keep your OAuth credentials secure and never commit them to version control.