An open-source browser extension that makes legal language accessible by connecting webpage text selections to the Justice Definitions Project. This extension allows users to quickly look up legal definitions and contribute new terms for definition.
- Quick Definition Lookup: Select any legal term on any webpage and get instant definitions
- Side Panel Interface: Clean, non-intrusive side panel for seamless browsing experience
- Request New Definitions: Submit terms that need definitions to help expand the database
- Geographic Logging: Optional IP-based geographic tracking for analytics
- Rate Limiting: Built-in protection against abuse
- Self-Hosted: Complete control over your data and infrastructure
- Customizable: Easily modify to work with your own definition database
- Google account (for Google Apps Script and Google Sheets)
- Modern browser (Chrome, Firefox, Edge, Safari)
- Basic knowledge of browser extension development (optional)
The extension provides two main ways to access legal definitions:
- Right-Click Lookup: Select any legal term and right-click for instant definitions
- Side Panel Search: Click the extension icon to open a dedicated search interface
Both methods allow you to request new definitions if they're not found in the database.
Select any legal term on any webpage and right-click for instant definition previews in a floating popup.
Click the extension icon to open the sliding overlay panel with built-in search and request functionality.
-
Create a new Google Apps Script project:
- Go to script.google.com
- Click "New Project"
- Replace the default code with the contents of
google-apps-script/Code.gs
-
Configure the script:
- Replace all placeholder values in the
CONFIGobject:const CONFIG = { SHEET_ID: 'YOUR_GOOGLE_SHEET_ID_HERE', // Your Google Sheet ID SECURITY: { ACCESS_KEY: 'your_secure_access_key_here', // Your secret key ENABLE_ACCESS_KEY_VALIDATION: true }, // ... other configurations };
- Replace all placeholder values in the
-
Create a Google Sheet:
- Create a new Google Sheet
- Copy the Sheet ID from the URL (the long string between
/d/and/edit) - Update the
SHEET_IDin your Apps Script
-
Deploy the script:
- Click "Deploy" → "New deployment"
- Choose "Web app" as the type
- Set "Execute as" to "Me"
- Set "Who has access" to "Anyone"
- Copy the deployment URL
-
Update configuration files:
- Open
extension/config.js - Replace
YOUR_GOOGLE_APPS_SCRIPT_DEPLOYMENT_ID_HEREwith your deployment ID - Open
extension/background.js - Replace the webhook endpoint and access key with your values
- Open
-
Load the extension:
- Open Chrome/Edge: Go to
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked" and select the
extensionfolder - Pin the extension to your toolbar
- Open Chrome/Edge: Go to
├── extension/ # Browser extension files
│ ├── manifest.json # Extension manifest
│ ├── background.js # Background script
│ ├── content.js # Content script
│ ├── config.js # Configuration file
│ ├── popup/ # Extension popup
│ ├── sidepanel/ # Side panel interface
│ ├── options/ # Extension options page
│ └── assets/ # Icons and images
├── google-apps-script/ # Backend server code
│ └── Code.gs # Google Apps Script code
├── docs/ # Documentation
│ ├── SETUP_GUIDE.md # Setup instructions
│ ├── SECURITY.md # Security guidelines
│ └── PRIVACY_POLICY.md # Privacy policy
├── LICENSE # MIT License
├── CONTRIBUTING.md # Contribution guidelines
└── README.md # This file
SECURITY: {
ENABLE_ACCESS_KEY_VALIDATION: true, // Require access key for requests
ACCESS_KEY: 'your_secure_key', // Secret key for authentication
LOG_REQUESTS: true, // Log all requests
LOG_IP_ADDRESSES: true, // Log IP addresses
LOG_GEOGRAPHY: true // Log geographic data
}RATE_LIMIT_ENABLED: true,
MAX_REQUESTS_PER_HOUR: 1000, // Maximum requests per hour per user
MAX_REQUESTS_PER_MINUTE: 30 // Maximum requests per minute per userGEOGRAPHIC_LOGGING: {
ENABLED: true, // Enable geographic tracking
LOG_NON_INDIA_REQUESTS: true, // Log requests from outside India
LOG_ALL_REQUESTS: false // Log all requests regardless of location
}To connect to your own definition database instead of the Justice Definitions Project:
-
Update the API endpoint in
extension/config.js:const DEFAULT_CONFIG = { API_URL: "https://your-api-endpoint.com/api", // ... other settings };
-
Modify the search logic in the content and side panel scripts to match your API's response format.
- Icons: Replace files in
extension/assets/with your own icons - Colors: Modify CSS in
extension/sidepanel/sidepanel.cssandextension/popup/style.css - Text: Update strings in the HTML and JavaScript files
The extension is built with a modular architecture:
- Background Script (
extension/background.js): Handles extension lifecycle and webhook requests - Content Script (
extension/content.js): Manages text selection and side panel integration - Side Panel (
extension/sidepanel/): Contains the main user interface - Options Page (
extension/options/): Extension settings and configuration
- Use HTTPS: Always use HTTPS for your webhook endpoints
- Rotate Keys: Regularly change your access keys
- Monitor Logs: Review your Google Sheets logs regularly
- Rate Limiting: Adjust rate limits based on your usage patterns
- IP Restrictions: Consider adding IP allowlists if needed
- IP Logging: Can be disabled by setting
LOG_IP_ADDRESSES: false - Geographic Data: Can be disabled by setting
GEOGRAPHIC_LOGGING.ENABLED: false - Request Logging: Can be disabled by setting
LOG_REQUESTS: false
-
Extension not loading:
- Check that all files are in the
extensionfolder - Verify
manifest.jsonis valid JSON - Check browser console for errors
- Check that all files are in the
-
Webhook requests failing:
- Verify your Google Apps Script deployment URL
- Check that your access key matches in both files
- Review Google Apps Script execution logs
-
Definitions not loading:
- Check network requests in browser dev tools
- Verify API endpoints are accessible
- Check for CORS issues
Enable debug logging by adding this to your configuration:
const DEBUG = true;We welcome contributions! Here's how you can help:
- 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
- Clone the repository
- Set up your own Google Apps Script backend
- Configure the extension with your credentials
- Load the extension in developer mode
- Make your changes and test them
This project is licensed under the MIT License - see the LICENSE file for details.
- Justice Definitions Project for the original concept
- Google Apps Script for the backend infrastructure
- The open-source community for inspiration and tools
Note: This is an open-source version of the Justice Definitions Project browser extension. Replace all placeholder values with your own credentials before use. Never commit secrets to public repositories.