Skip to content

Detect browser (Chrome, IE, Firefox etc...) Developer Tools (Console) is opened

License

Notifications You must be signed in to change notification settings

dsa28s/detect-browser-devtools

Repository files navigation

detect-browser-devtools

Detect browser (Chrome, IE, Firefox etc...) Developer Tools (Console) is opened

Install

Use npm:

$ npm install browser-detect-devtools

Use cdn:

<script src="https://unpkg.com/browser-detect-devtools/dist/detect-browser-devtools.min.js"></script>

Usage

NPM

const devTools = require('browser-detect-devtools');
const devToolsManager = devTools.Manager;
// Always want to clear console log of the browser's developer tools, use `alwaysConsoleClear` API.
devToolsManager.alwaysConsoleClear(true); // enable function
devToolsManager.alwaysConsoleClear(false); // disable function

// Pause the browser session when Browser's developer tools are open, use `freezeWhenDevToolsOpened` API.
devToolsManager.freezeWhenDevToolsOpened(true); // enable function
devToolsManager.freezeWhenDevToolsOpened(false); // disable function

// You can also receive events developer tools are opened, closed, and get position.
// IMPORTANT : Use this function only when in release mode.
// If you call this method, the console.log is reset regardless of the alwaysConsoleClear function called.
devToolsManager.startDevToolMonitoring((isOpened, orientation) => {
  // orientation : 'horizontal' / 'vertical' / 'separated-window'
});

// Stop monitoring devtools event.
devToolsManager.stopDevToolMonitoring();

CDN

CDN create instance to global variable.

// Always want to clear console log of the browser's developer tools, use `alwaysConsoleClear` API.
DevTools.Manager.alwaysConsoleClear(true); // enable function
DevTools.Manager.alwaysConsoleClear(false); // disable function

// Pause the browser session when Browser's developer tools are open, use `freezeWhenDevToolsOpened` API.
DevTools.Manager.freezeWhenDevToolsOpened(true); // enable function
DevTools.Manager.freezeWhenDevToolsOpened(false); // disable function

// You can also receive events developer tools are opened, closed, and get position.
// IMPORTANT : Use this function only when in release mode.
// If you call this method, the console.log is reset regardless of the alwaysConsoleClear function called.
DevTools.Manager.startDevToolMonitoring((isOpened, orientation) => {
  // orientation : 'horizontal' / 'vertical' / 'separated-window'
});

// Stop monitoring devtools event.
DevTools.Manager.stopDevToolMonitoring();

See the top gif image in the README.md file for details on how to do this.

License

MIT

About

Detect browser (Chrome, IE, Firefox etc...) Developer Tools (Console) is opened

Resources

License

Stars

Watchers

Forks

Packages

No packages published