-4

Using following script I can make a error when user inpect on web browser. Within following script, can I delete entire div element when user trying to inpect on web browser?

<script type="text/javascript">
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(3(){(3 a(){8{(3 b(2){7((\'\'+(2/2)).6!==1||2%5===0){(3(){}).9(\'4\')()}c{4}b(++2)})(0)}d(e){g(a,f)}})()})();',17,17,'||i|function|debugger|20|length|if|try|constructor|||else|catch||5000|setTimeout'.split('|'),0,{}))
</script>
isuru
  • 3,385
  • 4
  • 27
  • 62
  • Where did you find this script? Does it come with some documentation maybe? – sjahan Jun 14 '18 at 12:44
  • @sjahan from https://stackoverflow.com/questions/24319786/how-to-hide-form-code-from-view-code-inspect-element-browser/24320533 – isuru Jun 14 '18 at 12:45
  • I'm voting to close this question as off-topic because of malicious intent. – AndrewL64 Jun 14 '18 at 12:46
  • @AndrewL Actually I don't know what happens inside that script. I got that one from https://stackoverflow.com/questions/24319786/how-to-hide-form-code-from-view-code-inspect-element-browser/24320533 – isuru Jun 14 '18 at 12:47
  • 1
    @isuru Just as one of the users in your provided link rightly said, `To put it simple, if you do not want people to get something in their browser, you should never send it to their browser in the first place.` – AndrewL64 Jun 14 '18 at 12:49
  • Even if you could disable the dev tools, one interested user still could sniff the HTTP response with another tool than the browser and get the HTML. You cannot really protect it. – sjahan Jun 14 '18 at 12:52
  • @sjahan Is my above script malicious? – isuru Jun 14 '18 at 12:57
  • 1
    @isuru I don't know and I don't want to try it ;) `eval` is evil. – sjahan Jun 14 '18 at 12:58

1 Answers1

1

If you want to detect whether dev tools is opened or not use this library.

<script src="node_modules/devtools-detect/index.js"></script>
<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);
    });
</script>
Dis_Pro
  • 633
  • 1
  • 10
  • 21