LeslieLeung
124 天前
看到一楼的回复好奇试了下。
这个防控制台打开的方法也太拙劣了,检测逻辑就是两个:一个控制台高度阈值,一个开发者工具快捷键拦截。甚至因为 arc 本身的布局,一打开就会触发检测。
绕过方法:Arc 浏览器全屏,把开发者工具弹出方式改为单独窗口。
```
checkConsoleOpen: function checkConsoleOpen() {
var threshold = 160; // 自定义控制台高度阈值
setInterval(function () {
if (window.outerHeight - window.innerHeight > threshold || window.outerWidth - window.innerWidth > threshold) {
alert("控制台已打开,禁止查看源代码!");
window.location.reload(); // 可选:刷新页面或隐藏内容
}
}, 1000);
}
if (true) {
if (localStorage.getItem('allowopenf12') != true && localStorage.getItem('allowopenf12') != 'true') {
this.checkConsoleOpen();
// 禁用右键菜单
document.addEventListener('contextmenu', function (event) {
return event.preventDefault();
});
document.addEventListener('keydown', function (event) {
if (event.key === 'F12' ||
// F12
event.ctrlKey && event.shiftKey && event.key === 'I' ||
// Ctrl+Shift+I
event.ctrlKey && event.shiftKey && event.key === 'J' ||
// Ctrl+Shift+J
event.ctrlKey && event.key === 'U' // Ctrl+U
) {
event.preventDefault();
}
});
}
}
```
说实话,开发者工具真没必要防吧,想看你接口我抓包也行,一万种方法。