<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: VikramJS</title>
    <description>The latest articles on DEV Community by VikramJS (@oceanrational).</description>
    <link>https://dev.to/oceanrational</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F441384%2F39bc2a44-5682-4916-b1b3-af93b05d1b8c.jpeg</url>
      <title>DEV Community: VikramJS</title>
      <link>https://dev.to/oceanrational</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oceanrational"/>
    <language>en</language>
    <item>
      <title>Chrome Devtools Detection by Website</title>
      <dc:creator>VikramJS</dc:creator>
      <pubDate>Wed, 24 Nov 2021 08:34:32 +0000</pubDate>
      <link>https://dev.to/oceanrational/chrome-devtools-detection-by-website-1n34</link>
      <guid>https://dev.to/oceanrational/chrome-devtools-detection-by-website-1n34</guid>
      <description>&lt;p&gt;Hi, &lt;/p&gt;

&lt;p&gt;mY name is Vikram and i am recently jumped into CodingWorld. &lt;br&gt;
Initially i was learning laravel and now im in vuejs. &lt;/p&gt;

&lt;p&gt;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. &lt;/p&gt;

&lt;p&gt;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. &lt;/p&gt;

&lt;p&gt;If here in this community any one help me out it will be appreciated. &lt;br&gt;
Here is my code &lt;a href="https://pastebin.com/PBpRC2dB"&gt;https://pastebin.com/PBpRC2dB&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

const debuggerCheck = null;
      var aCheck = false;
      class devtools {
    constructor() { }
    static toString() {
        // alert('in')
        aCheck = true;
        return "-";
    }
}

       setInterval(() =&amp;gt; {
        console.profile(devtools);
        // alert(a)
        if (aCheck) {
          localStorage.setItem("check", 1); 
          document.body.innerHTML =
            '&amp;lt;h2 style="width:100%;text-align:center; margin-top:100px "&amp;gt;&amp;lt;strong&amp;gt;Sorry&amp;lt;/strong&amp;gt;, but you have opened Developer Tools and you can\'t continue using this app.&amp;lt;/h2&amp;gt;';
          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 &amp;amp;&amp;amp; e.shiftKey &amp;amp;&amp;amp; e.keyCode == 'I'.charCodeAt(0)) { 
                return false; 
            } 
            if (e.ctrlKey &amp;amp;&amp;amp; e.shiftKey &amp;amp;&amp;amp; e.keyCode == 'C'.charCodeAt(0)) { 
                return false; 
            } 
            if (e.ctrlKey &amp;amp;&amp;amp; e.shiftKey &amp;amp;&amp;amp; e.keyCode == 'J'.charCodeAt(0)) { 
                return false; 
            }
            if (e.ctrlKey &amp;amp;&amp;amp; e.keyCode == 'C'.charCodeAt(0)) { 
                return false; 
            } 
            if (e.ctrlKey == true &amp;amp;&amp;amp; (e.which == '67')) {
                return false;
            }
            if (e.ctrlKey &amp;amp;&amp;amp; e.keyCode == 'U'.charCodeAt(0)) { 
                return false; 
            }
            if (e.ctrlKey &amp;amp;&amp;amp; e.keyCode == 'S'.charCodeAt(0)) { 
                return false; 
            } 
       }
    //    document.addEventListener('contextmenu', function(e) {
    //         e.preventDefault();
    //         }, false);



 export default {debuggerCheck}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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. &lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

</description>
      <category>devtools</category>
      <category>detection</category>
      <category>website</category>
    </item>
  </channel>
</rss>
