A comprehensive JavaScript-based solution for blocking developer tools access and protecting web content from inspection.
- Modern Implementation: Uses
event.key
instead of deprecatedkeyCode
- Cross-Platform Support: Works on Windows, Mac, and Linux
- Comprehensive Coverage: Blocks all major dev tools shortcuts
F12
- Developer ToolsCtrl+Shift+I/C/J/K
- Various dev tools (Windows/Linux)Cmd+Alt+I/C/J/K
- Mac equivalentsCtrl+U
/Cmd+U
- View Source
- 8 Detection Methods: Multiple detection approaches for maximum accuracy
- Timing Detection: Debugger execution time analysis
- Console Access: Property getter triggers on dev tools access
- Function Debugger: Dynamic function creation with debugger
- Window Size: Outer vs inner window dimension comparison
- Console Redirect: Console method override detection
- Element Inspection: DOM element property access monitoring
- Network Monitoring: XMLHttpRequest override detection
- Source Access: Script source property access detection
- Smart Filtering: Requires multiple methods to agree, reducing false positives
- Performance Optimized: Throttled checks to prevent performance impact
- Visual Feedback: Warning overlay with blur effects when detected
- Environment Check: Detects headless browsers and automation tools
- Context Menu Blocking: Prevents right-click access to dev tools
- Text Selection Blocking: Prevents content selection and copying
- Drag Prevention: Blocks dragging elements to inspect them
- Console Method Monitoring: Detects when console functions are used
- Eval Disabling: Prevents code injection via eval()
- Visual Warning System: Blur effects and overlay warnings
- Suspicious Environment Detection: Identifies automated browsers and tools
blocker.html
- Improved keyboard shortcut and basic dev tools detectiondetect.html
- Enhanced multi-method developer tools detectionenhanced-blocker.html
- Recommended - Complete solution with all features
Include the script in your HTML:
<script src="blocker.html"></script>
Use the enhanced version for full protection:
<!-- Copy the script from enhanced-blocker.html -->
The enhanced version allows customization:
// Access configuration object
window.consoleBlockerConfig.enableContextMenu = true; // Allow right-click
window.consoleBlockerConfig.detectionInterval = 5000; // Check every 5 seconds
Option | Default | Description |
---|---|---|
detectionThreshold |
100 | Milliseconds delay threshold for debugger detection |
maxDetectionAttempts |
3 | Number of attempts before triggering action |
detectionInterval |
2000 | Milliseconds between periodic checks |
throttleInterval |
500 | Milliseconds throttle for event-based checks |
enableContextMenu |
false | Allow right-click context menu |
enableTextSelection |
false | Allow text selection |
enableKeyboardShortcuts |
true | Block keyboard shortcuts |
enableDevToolsDetection |
true | Enable active dev tools detection |
- ✅ Modern JavaScript: Uses ES6+ features and best practices
- ✅ Performance: Optimized with throttling and efficient detection
- ✅ Maintainability: Clean, modular code structure
- ✅ Error Handling: Comprehensive try-catch blocks
- ✅ Configuration: Easy customization options
- ✅ Cross-Browser: Works in all modern browsers
- ✅ Mobile Support: Responsive and mobile-friendly
- ✅ Legacy Support: Graceful degradation for older browsers
- ✅ Multiple Detection Methods: Harder to bypass
- ✅ Smart Detection: Reduces false positives
- ✅ Configurable Actions: Customizable response to detection
- Not Foolproof: Skilled developers can still bypass these protections
- Performance Impact: Active detection may slightly impact page performance
- User Experience: May interfere with legitimate user interactions
- Use as part of a broader security strategy
- Consider server-side protections for sensitive content
- Test thoroughly with your specific use case
- Monitor for false positives and adjust configuration as needed
These client-side protections should not be relied upon for critical security:
- JavaScript can be disabled by users
- Source code is visible to determined users
- Browser extensions can bypass many restrictions
- Mobile browsers may behave differently
For sensitive content, implement server-side access controls and authentication.
- Timing Detection: Measures debugger statement execution time
- Console Access: Detects when console objects are accessed via property getters
- Function Debugger: Uses Function constructor with debugger statements
- Window Size: Compares outer vs inner window dimensions for dev tools presence
- Console Redirect: Monitors console method overrides and redirection
- Element Inspection: Detects DOM element property access that indicates inspection
- Network Monitoring: Identifies XMLHttpRequest monitoring and modification
- Source Access: Detects attempts to access script source properties
Add ?debug=true
to your URL to enable debug mode:
- Shows detection method results in console
- Allows console usage without triggering alerts
- Useful for testing and development
To modify or extend the blocker:
- Edit the configuration object for simple changes
- Add new detection methods to the
detectionMethods
object - Customize the
handleDevToolsDetection
function for different responses - Test across different browsers and scenarios
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please:
- Test your changes across multiple browsers
- Maintain backward compatibility when possible
- Document any new configuration options
- Consider performance impact of new features
- ✅ Added 8 different detection methods for enhanced accuracy
- ✅ Implemented visual warning overlay system
- ✅ Added suspicious environment detection
- ✅ Enhanced console method monitoring
- ✅ Improved user feedback with detailed detection info
- ✅ Added page blur effect when dev tools detected
- ✅ Implemented additional bypass protection measures
- ✅ Replaced deprecated
keyCode
with modernkey
property - ✅ Added comprehensive Mac support
- ✅ Implemented multiple detection methods
- ✅ Added configuration system
- ✅ Improved performance with throttling
- ✅ Enhanced error handling
- ✅ Added complete HTML example
- Basic keyboard shortcut blocking
- Simple debugger timing detection
- Event-based detection triggers
- Choi Minseo - minseo0388
- Department of Chemistry, College of Natural Sciences, Chungnam National University, South Korea