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

标签 javascript image console 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)

关于javascript - 检测是否通过 getter 查看图像(在控制台中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65430731/

相关文章:

java - 当我通过 RDP 连接或更改分辨率时,为什么会收到 java.lang.NullPointerException?

javascript - 检索 JSON 对象列表中的最后一个对象

javascript - 拖放文件上传多个并在上传前预览 - php、javascript

android - 从 SD 卡上传图片到 Facebook - Android

linux - 在 Ubuntu 中个性化差异命令

javascript - 每次页面内容更改时控制台都会获取 .text()

javascript - 如何在未经身份验证的情况下通过 XHR (CORS) 访问公共(public) Google Drive 文件?

javascript - 更改子元素 CSS 包含类 active

javascript - React Native Image 如何使用 onError

html - 以图像为中心的导航菜单