【问题标题】:Detect user inspect and remove entire div检测用户检查并删除整个 div
【发布时间】:2018-11-24 06:01:09
【问题描述】:

当用户在网络浏览器上进行检查时,使用以下脚本可能会出错。在以下脚本中,当用户尝试在 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>

【问题讨论】:

  • 你在哪里找到这个脚本?它可能附带一些文档吗?
  • 出于恶意,我投票决定将此问题作为题外话结束。
  • @isuru 正如您提供的链接中的一位用户正确地说的那样,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.
  • @isuru 我不知道也不想尝试 ;) eval 是邪恶的。

标签: javascript html


【解决方案1】:

如果要检测开发工具是否打开,请使用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>

【讨论】:

    猜你喜欢
    • 2019-05-28
    • 2019-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-08
    • 1970-01-01
    • 2021-04-04
    相关资源
    最近更新 更多