-4

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?

newcool
  • 319
  • 2
  • 20
  • 1
    To what end, exactly? – jonrsharpe Jun 08 '19 at 21:19
  • @jonrsharpe Just like "DevTools is open" or "DevTools are closed" – newcool Jun 08 '19 at 21:24
  • 1
    And why do you want that? Again, what *problem* are you trying to solve? Your client-side code is publicly visible, it has to be to actually work. Also, realistically, most people won't care. – jonrsharpe Jun 08 '19 at 22:22
  • @jonrsharpe I dont understand why you are so adamant about this. The question is can you or can you not detect when the DevTools are open on Firefox. Simple question you are making hard to answer for no reason. – newcool Jun 08 '19 at 22:25
  • 1
    Because without a reason, a concrete problem to solve, it's an [XY problem](http://xyproblem.info). – jonrsharpe Jun 08 '19 at 22:27
  • @jonrsharpe That is literally the concrete problem in the title. Can you detect if Firefox Devtools are open. If you could how would you go about it. That's it, that's all I want. Nothing more nothing less. You are making this more complicated than it should be. – newcool Jun 08 '19 at 22:30
  • 1
    No, it's not, but I won't waste any more of my time on this. – jonrsharpe Jun 08 '19 at 22:30
  • IMO you shouldn't really bother with this. Since all frontend data is downloaded to the browser (js included) it's not terribly hard to disable any counteraction you implement. If your target isn't crafty enough to know this, then an uglifier/minifier is probably all you need. In cases of annoying freedom-limiting scripts (right-click, selection, ugh, I hate all those) I usually disable JS for that page with noscript. All that said, I wouldn't spend time on this. – Albert Jun 08 '19 at 23:51

1 Answers1

2

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.

BrJ
  • 574
  • 3
  • 7