DevTools是否已打开

DevTools是否已打开

本文介绍了您如何检测firefox DevTools是否已打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜寻高低,但我所能找到的就是检测chrome开发工具和 FireBUG 开发工具的方法.是否可以在 Firefox 上检测到Inspect Element/console/Dev Tool已打开?

I've been searching high and low but all I could find are ways to detect chrome Dev Tools and FireBUG Dev Tools. Is there a way to detect, on Firefox, that the Inspect Element/console/Dev Tool is open?

推荐答案

如果不从被访问的客户端中真正删除上述代码,则实际上无法隐藏您的客户端源代码.这样做的简单原因是必须将代码下载到客户端才能使用.下载后,对用户可见.没有例外.您可以做类似"通过默默无闻的安全性"这样的操作,但这也不会阻止人们从下载/查看源代码.这只会使代码更难阅读.

It is impossible to actually hide your client side source code without actually removing said code from being accessed client side. The simple reason for this is the fact that the code has to be downloaded to the client for it to be used. Once downloaded, it's visible to the user. No exceptions. You can do things like 'security through obscurity', but that too is not going to prevent people from downloading/viewing the source. It's just going to make the code harder to read.

如果要阻止用户看到您的代码,则基本上被迫处理要隐藏在服务器端的代码部分.这样,只有输入和输出对用户可见,同时隐藏了处理输入和输出的逻辑.

If you want to prevent users from seeing your code, you're basically forced to handle the parts of the code you wish to hide server side. This way, only the input and output are visible to users, while hiding the logic that processes it.

还有一些其他的技巧可以使您难以访问代码(并非不可能),但是我也不建议您这样做.这些通常取决于浏览器的安全设置,可以通过浏览器附加组件等轻松阻止.

There are some other tricks you could potentially do to make it harder to acces your code (not impossible by a long shot), but I wouldn't recommend those either. Those are usually reliant on browser security settings, easily prevented through broswer add-ons, etc.

如果相反,因为您正在处理安全敏感的操作客户端,而希望阻止用户看到您的代码,则建议您回到Web开发101并检查为什么这是一个固有的坏主意.

If instead you want to prevent users from seeing your code, because you're handling security sensitive operations client side, I suggest you go back to web development 101 and check why that's an inherently bad idea.

要纯粹检测是否已打开DevTools,可以使用以下命令: https://github.com/sindresorhus/devtools-detect ,只需遵循自述文件即可.

To purely detect if DevTools is open, you can use this: https://github.com/sindresorhus/devtools-detect and simply follow the readme.

这篇关于您如何检测firefox DevTools是否已打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 01:28