1. Watching window.innerHeight/innerWidth for sudden, large decreases, indicating that the user just opened the inspector.
2. Logging objects to the console with toString methods and checking if that method gets called.
2. Ahhh, clever!
but 2. I have no idea, except the browser vendors would add a "stealth dev mode"
So your solution would require inject your code into the code that wants to hide from you ... ?
I might be off here, but I imagine console.log early exits if there's no console open, so it doesn't call toString
If that's the case you can just write to the console in a loop and immediately know if one is open
The point is to avoid calling toString when the console is open, by using some other way of displaying logged values.
Their code will call console.log(object) every X ticks.
As soon as you open the console, console.log fires instead of early exiting => object.toString is called => they know the console is open
My memory is fuzzy, but I also had a different function I would call if frameworks added it so instead of “Object {}” it was “Backbone.Model {id=1}”.
I put these in and used them in firebug extensions I wrote for frameworks.
Later I asked chrome to add something, which is why there is a “enable custom formatters” option for the console. Really needs to work in the debugger though.
Someone else is writing code that they want to have react to the console opening.
So they will intentionally force the call as soon as the console is open, as a result toString is called regardless of if you yourself have made a call to it.
The point is that you patch the console to not do that.
Even so, we added CSS and stuff to highlight elements and that was easily found.
What do people look for today?