8000 GitHub - vehbiu/detect-devtools: πŸ”’- Detect when DevTools are opened in JavaScript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vehbiu/detect-devtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” DETECT-DEVTOOLS

TypeScript JavaScript Bun

A lightweight, modular library for detecting when browser developer tools are opened, using multiple detection strategies.

🌟 Features

  • Multiple Detection Methods: Uses various strategies to detect DevTools opening
  • Modular Architecture: Easy to add or remove detection strategies
  • TypeScript Support: Fully typed for better development experience
  • Customizable Callbacks: Define custom actions when DevTools state changes
  • Minimal Dependencies: Pure JavaScript/TypeScript implementation

πŸš€ Installation

npm install --save detect-devtools

πŸ“‹ Usage

import { init } from 'detect-devtools';

// Initialize with a callback function
init((isOpen, type, detail) => {
    console.log(`DevTools ${isOpen ? 'opened' : 'closed'}`);
    console.log(`Detection method: ${type}`);
    console.log(`Additional details:`, detail);
});

HTML Example

Check /dist/example.html Live example: https://vehbiu.github.io/detect-devtools/dist/example.html

πŸ› οΈ Detection Strategies

The library uses multiple strategies to detect DevTools:

  1. Object ID Check: Monitors changes in object properties
  2. Performance Logging: Analyzes console.l 7FF6 og performance
  3. Debug Check: Checks for debug-related behaviors
  4. ToString Check: Evaluates function.toString() behavior

πŸ“ Project Structure

src/
β”œβ”€β”€ checks/
β”‚   β”œβ”€β”€ impl/
β”‚   β”‚   └── [...checkName].ts
β”‚   └── BaseCheck.ts
β”œβ”€β”€ util/
β”œβ”€β”€ index.ts
└── tsconfig.json

βš™οΈ API Reference

init(onChange?: OnChangeProps)

Initializes the detection system with an optional callback function.

type OnChangeProps = (
    open: boolean,    // true if DevTools is open
    type: string,     // detection method that triggered
    detail: object | string | null  // additional information
) => void;

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a new branch: git checkout -b feature/your-feature
  3. Make your changes
  4. Submit a pull request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Vehbi

πŸ™ Acknowledgments


Made with ❀️ for the developer community

About

πŸ”’- Detect when DevTools are opened in JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0