How do you detect if firefox DevTools is open? [duplicate]

跟風遠走 提交于 2020-01-30 13:31:38

问题


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?


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/56510212/how-do-you-detect-if-firefox-devtools-is-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!