How to use devtools-detect - 4 common examples

To help you get started, we’ve selected a few devtools-detect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github splincodewd / client-logger / aio / src / vendor.ts View on Github external
// Application Dependencies
declare const require: any;
import "./css/simple-grid.min.css";
import "./css/custom.css";
import "lodash";

let devtools = require("devtools-detect");
if (!devtools.open) {
    elementChangeClass("console-dis-activate", "no-display", "");
}

window.addEventListener('devtoolschange', function (e) {
    const devtoolsIsOpen = e['detail']['open'];
    if (devtoolsIsOpen) {
        elementChangeClass("console-activate", "no-display", "");
        elementChangeClass("console-dis-activate", "", "no-display");
    } else {
        elementChangeClass("console-dis-activate", "no-display", "");
        elementChangeClass("console-activate", "", "no-display");
    }
});

function elementChangeClass(idElement: string, removeClass: string, addClass: string) {
    removeClass ? document.getElementById(idElement).classList.remove(removeClass) : null;
github splincodewd / client-logger / demo / src / app / app.component.ts View on Github external
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import * as devtools from 'devtools-detect';
import { Examples } from './examples/examples.class';
import { environment } from '../environments/environment';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit {

  public loaded: boolean;
  public devToolsIsOpen: boolean = environment.stackblitz || devtools.open;
  public LoggerExamplesTemplate = Examples;

  public ngOnInit() {
    this.loaded = true;
    window.addEventListener('devtoolschange', (e) => {
      this.devToolsIsOpen = e['detail']['open'];
    });
  }
}
github OpenZeppelin / ethernaut / src / components / Ethernaut / ConsoleDetect.js View on Github external
checkConsole() {
    const isOpen = DevToolsDetect.open;
    if (this.state.consoleIsOpen !== isOpen) {
      this.setState({
        consoleIsOpen: isOpen,
      });
    }
  }
github OpenZeppelin / ethernaut / src / components / Ethernaut / ConsoleDetect.js View on Github external
import DevToolsDetect from 'devtools-detect';
import React from 'react';

class ConsoleDetect extends React.Component {
  state = {
    consoleIsOpen: !DevToolsDetect.open,
  };

  componentDidMount() {
    window.addEventListener('resize', () => {
      this.checkConsole();
    });
    this.checkConsole();
    setInterval(() => this.checkConsole(), 500);
  }

  checkConsole() {
    const isOpen = DevToolsDetect.open;
    if (this.state.consoleIsOpen !== isOpen) {
      this.setState({
        consoleIsOpen: isOpen,
      });

devtools-detect

Detect if DevTools is open and its orientation

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis

Popular devtools-detect functions