通过 getter 检测图像(在控制台中)是否被查看

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

我想制作一个小脚本来检查控制台是否打开。我看了很多帖子,大多数都说不可能了。然而,我发现一个这样说的:

... 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.

这可能吗?如果是,那我如何使用 getter 来完成?

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