检测用户检查并删除整个div

时间:2018-06-14 12:41:08

标签: javascript html

使用以下脚本我可以在用户在网络浏览器上查看时出错。在以下脚本中,当用户尝试在Web浏览器上进行检查时,是否可以删除整个div元素?

<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>

1 个答案:

答案 0 :(得分:1)

如果要检测是否已打开开发工具,请使用this库。

<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>