developer-tools-detector
v1.0.0
Published
Easily detect and block developer tools on any web server.
Downloads
30
Maintainers
Keywords
Readme
npm install developer-tools-detector
yarn add developer-tools-detector
consoleLog:
true or falsecheckDuration:
"Always" or Number in milisecondsblockIfDetected:
true or falseallowedPaths:
list of paths
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?
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}`);
});
Server is running at http://localhost:3000
Developer tools detected on the client!
If you have any issues don't hesitate to report it via GitHub Issues.
This package was made by @lazyfenix.