Detecting if image (in console) is looked at through getter

Viewed 54

I would like to make a small script that checks if the console is open. I looked at many posts and most say that it is not possible anymore. However, I found one that said this:

... I added a small script that would redirect the player to a 404 if they opened devtools. To accomplish this, I created an Image with a getter, which was logged to console. If console was opened, the getter would be triggered, and the user would be 404'd.

Is this possible? If it is, then how do I use a getter to accomplish?

1 Answers

var element = new Image()
Object.defineProperty(element, 'id', {
  get() {
    alert('Hello')
  }
})
console.log(element)

Related