Skip to content

Easily detect and block developer tools on any web server.

Notifications You must be signed in to change notification settings

lazyfenix/developer-tools-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DTD-Banner

Easily detect and block developer tools on any web server.

version downloads

Getting Started

Installation

Using NPM:

npm install developer-tools-detector

Using YARN:

yarn add developer-tools-detector

Usage

Detecting options

  • consoleLog: true or false

  • checkDuration: "Always" or Number in miliseconds

  • blockIfDetected: true or false

  • allowedPaths: list of paths

Legends

  • consoleLog - This option will log detection if enabled.

  • checkDuration - Set if you want to check for devtools always or only if first X ms time of user access on website.

  • blockIfDetected - Do you want to block (about:blank) user that will open devtools?

  • allowedPaths - What paths you want to have developer-tools-detection enabled on?

Import and usage example

You can use DTD (developer-tools-detector) on any web server. For example this is usage of DTD in express web server.

const express = require('express');
const { DevToolsDetector } = require('developer-tools-detector'); 

const app = express();
const port = 3000;

const allowedPaths = ['/protected'];

const detector = new DevToolsDetector(allowedPaths, {
    consoleLog: true,
    checkDuration: "always",
    blockIfDetected: false, 
});

app.post('/log-devtools-detected', (req, res) => {
    console.log("Developer tools detected on the client!");
    res.sendStatus(200);
});

app.get('/protected', (req, res) => {
    if (detector.isPathAllowed(req.path)) {
        const detectionScript = detector.getDetectionScript();

        res.send(`
            <html>
                <head>
                    <title>Protected Route</title>
                    ${detectionScript} <!-- Injects the DevTools detection script -->
                </head>
                <body>
                    <h1>This is a protected route!</h1>
                    <p>Your protected content goes here...</p>
                </body>
            </html>
        `);
    } else {
        res.status(403).send("Access Denied");
    }
});

app.get('/', (req, res) => {
    res.send('Hello World!');
});

app.listen(port, () => {
    console.log(`Server is running at http://localhost:${port}`);
});

Output example

Server is running at http://localhost:3000
Developer tools detected on the client!

Do you have any issues?

If you have any issues don't hesitate to report it via GitHub Issues.

This package was made by @lazyfenix.

About

Easily detect and block developer tools on any web server.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published