Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Chrome Devtools Detection by Website
VikramJS
VikramJS

Posted on • Edited on

     

Chrome Devtools Detection by Website

Hi,

mY name is Vikram and i am recently jumped into CodingWorld.
Initially i was learning laravel and now im in vuejs.

As a new bie to this world. I was working on devtools auto detect by website and if detected hide the all content. Once user closed the inspect window reload the site and voila! content shown.

after Much googling and overflowing stacking. I ended up in a bottle neck where if inspect window is undocked outside and if closed it should reload the website but not doing so.

If here in this community any one help me out it will be appreciated.
Here is my codehttps://pastebin.com/PBpRC2dB

const debuggerCheck = null;      var aCheck = false;      class devtools {    constructor() { }    static toString() {        // alert('in')        aCheck = true;        return "-";    }}       setInterval(() => {        console.profile(devtools);        // alert(a)        if (aCheck) {          localStorage.setItem("check", 1);           document.body.innerHTML =            '<h2><strong>Sorry</strong>, but you have opened Developer Tools and you can\'t continue using this app.</h2>';          aCheck = false;        } else {          check();        }        console.profileEnd(devtools);        console.clear()      }, 1000);      function check() {        if (localStorage.getItem("check") == 1) {          window.location.reload();          localStorage.setItem("check", 2);        }      }      document.onkeydown = function(e) {                     if (e.keyCode == 123) {                 return false;             }             if (e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {                 return false;             }             if (e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {                 return false;             }             if (e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {                 return false;             }            if (e.ctrlKey && e.keyCode == 'C'.charCodeAt(0)) {                 return false;             }             if (e.ctrlKey == true && (e.which == '67')) {                return false;            }            if (e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {                 return false;             }            if (e.ctrlKey && e.keyCode == 'S'.charCodeAt(0)) {                 return false;             }        }    //    document.addEventListener('contextmenu', function(e) {    //         e.preventDefault();    //         }, false); export default {debuggerCheck}
Enter fullscreen modeExit fullscreen mode

It should work like if user opened console/inspect element window, All the site content blocked by an msg and if console is closed site content visible again. And if console window is undocked and then closed it must do the same but not doing.

I was working on this piece of code from couple of days and found no solution yet. Hence posting this article here in search of answers and idea.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
menjilx profile image
Menj
  • Joined
• Edited on• Edited

This trick ->pastebin.com/PBpRC2dB is still working on chrome, brave and safari. :)
But I haven't tried the sample code above.

Thanks for sharing this code!

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Working On CodeIgniter 4 and Laravel
  • Location
    Delhi
  • Work
    Software Developer at LBM Solutions
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp