判断开发者工具有没有打开代码

开发 文章 2021-02-04 16:09 184 0 全屏看文

AI助手支持GPT4.0

unction checkDevTools(options) {const isFF = ~navigator.userAgent.indexOf("Firefox");
let toTest = '';if (isFF) {
toTest = /./;
toTest.toString = function() {
options.opened();
}
} else {
toTest = new Image();
toTest.__defineGetter__('id', function() {
options.opened();
});
}
setInterval(function() {
options.offed();
console.log(toTest);
console.clear && console.clear();
}, 1000);
}

checkDevTools({
opened: function() {
document.body.innerHTML = 'Dev Tools is on';
},
offed: function() {
document.body.innerHTML = 'Dev Tools is off';
}
});


-EOF-

AI助手支持GPT4.0