1

I am using below code to detect dev tool is open or not. It's working fine for chrome but it's not working for Mozilla Firefox. I am using 53.00 version of firefox.

    var checkStatus;

    var element = new Image();
    // var element = document.createElement('any');
    element.__defineGetter__('id', function() {
        checkStatus = 'on';
    });

    setInterval(function() {
        checkStatus = 'off';
        console.log(element);
        console.clear();
        document.querySelector('#devtool-status').innerHTML = checkStatus;
    }, 1000)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • @KiranDash Please read my question carefully, I've provided the code and my problem is, the code is not working for mozilla –  Aug 31 '17 at 12:33
  • Yes. Please check the answer in the link I shared, It shows how to detect if console is open on firefox. The code you wrote will only work for Chrome devtool and not firefox. – Kiran Dash Aug 31 '17 at 12:35
  • @KiranDash Thanks for sharing the link, but I want to implement it by only this code which I've added to a question. Is there anything missing in my code? or this code doesn't work for firefox? –  Aug 31 '17 at 12:37

1 Answers1

3

Here is following script for that. Hope this what you are looking for.

https://github.com/sindresorhus/devtools-detect/blob/gh-pages/index.js

Get and include it and then look following is the code which will help you to sort out your issue.

<script>
// check if it's open
console.log('is DevTools open?', window.devtools.open);
// check it's orientation, null if not open
console.log('and DevTools orientation?', window.devtools.orientation);

// get notified when it's opened/closed or orientation changes
window.addEventListener('devtoolschange', function (e) {
    console.log('is DevTools open?', e.detail.open);
    console.log('and DevTools orientation?', e.detail.orientation);
});

Ravi gohil
  • 89
  • 4