コード

var e = Object.defineProperty(document.createElement("DevToolDetector"), "id", {
  get: () => {
    // detect devtool
  }
})
console.dir(e)

仕組み

console.dir が DOM 要素を展開しようとする時、DevTools が開いていれば、 element.id 要素を取得しに行く。その結果 getter が走ことで検知できる。

使えるのか

Chrome Canary (67) では対策済みなので、次のバージョンぐらいでは使えなくなると思います。

9428contribution

Chrome 65 (Beta channel) でも動作しなさそう

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.