A Tampermonkey userscript that automatically redirects HTTP URLs to HTTPS and handles mixed content security issues. This script helps protect your browsing by ensuring secure connections whenever possible.
- 🔒 Automatic HTTP to HTTPS redirection
- 🛡️ Mixed content protection (upgrades HTTP resources to HTTPS)
- ⚪ Whitelist support for trusted domains
- 📝 Console logging for tracking redirects
- 🔄 Retry mechanism for failed HTTPS attempts
- ⚙️ Configurable settings via Tampermonkey menu
-
Install the Tampermonkey browser extension:
-
Click on the Tampermonkey icon in your browser
-
Select "Create a new script"
-
Copy the entire contents of
safety-protocol.jsinto the editor -
Save the script (Ctrl+S or File > Save)
The script runs automatically on all websites. You can control its behavior through the Tampermonkey menu:
- Click the Tampermonkey icon in your browser
- Find "Safety Protocol" in the menu
- Click "Enable Safety Protocol" to toggle the whitelist feature on/off
By default, the following domains are whitelisted (allowed to use HTTP):
- localhost
- 127.0.0.1
These domains are useful for local development and testing.
To test the script locally:
- Navigate to the
testdirectory - Start a local server:
python3 -m http.server 8080 # or npx http-server # or npx live-server --port=8080 # or ruby -run -ehttpd . -p8080 # or cargo install miniserve && miniserve --port 8080
- Open
http://localhost:8080/test.htmlin your browser - Check the browser console (F12) to see redirect logs
The script includes several configurable options in the CONFIG object:
enableWhitelist: Toggle whitelist functionalitywhitelistedDomains: Array of domains allowed to use HTTPlogRedirects: Enable/disable console logginghandleMixedContent: Automatically upgrade mixed content to HTTPSretryFailedHttps: Retry failed HTTPS connectionsmaxRetries: Maximum number of retry attempts
- Automatic HTTPS Upgrade: Redirects HTTP URLs to their HTTPS equivalents
- Mixed Content Protection: Upgrades HTTP resources (images, scripts, etc.) to HTTPS
- Whitelist System: Allows exceptions for trusted domains
- Retry Mechanism: Handles failed HTTPS attempts gracefully
@Author: Mitul Patel