```
let _console = {
log : console.log,
info :
console.info,
warn : console.warn,
error : console.error
};
var observerConsole = {
openCallback: function(){
_console.log('控制台打开了');
try {
window.open("about:blank", "_self")
} catch(e) {
var btn = document.createElement("button");
btn.onclick = function() {
window.open("about:blank", "_self")
}
btn.click()
}
},
observer: function(){
//这里使用 dom 元素,在打开控制台时才会计算 id
var dom = document.createElement("div"), that = this;
Object.defineProperty(dom, "id", {
get: function(){
that.openCallback()
}
})
//ie 不支持 console.table
//
console.info(dom);
_console.log(dom);
},
observerF: function(){
var obj = Object.create(null), t = Date.now(), that = this;
Object.defineProperty(obj, "a", {
get: function() {
if(Date.now() - t > 100){
that.openCallback()
}
}
})
setInterval(function(){
t = Date.now();
(function(){})["constructor"]("debugger")();//debugger;
_console.log(obj.a);
}, 200)
},
init: function(){
var t = window.navigator.userAgent.toLowerCase();
t.indexOf("firefox") >= 0 ? this.observerF() : this.observer();
}
}
observerConsole.init();
```
啊这。