From 69e864bcfbb0ec963a9971bc31fed29a40138081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=8B=87=E7=A5=A5?= <237899745@qq.com> Date: Mon, 17 Nov 2025 19:57:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A3=80=E6=B5=8B=E9=98=B2=E6=8A=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了用户可以在其他页面先打开F12控制台,然后访问网站时绕过禁用的问题。 主要改进: - 页面加载时立即检测开发者工具是否已打开 - 新增 debugger 断点检测机制,检测更灵敏 - 检测到开发者工具时显示美观的全屏警告页面 - 防止重复警告显示 - 调试模式下所有保护机制自动禁用 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/app.html | 96 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/frontend/app.html b/frontend/app.html index 0478136..198bc9a 100644 --- a/frontend/app.html +++ b/frontend/app.html @@ -2254,24 +2254,100 @@ (function() { const threshold = 160; let isDevToolsOpen = false; + let warningShown = false; - setInterval(function() { + // 增强型检测:结合窗口尺寸和debugger暂停 + function checkDevTools() { const widthThreshold = window.outerWidth - window.innerWidth > threshold; const heightThreshold = window.outerHeight - window.innerHeight > threshold; - const orientation = widthThreshold ? 'vertical' : 'horizontal'; - if (!(heightThreshold && widthThreshold) && - ((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) { - if (!isDevToolsOpen) { - isDevToolsOpen = true; - // 检测到开发者工具打开,可以选择清空页面或重定向 - // document.body.innerHTML = '

请关闭开发者工具

'; + // 检测是否有开发者工具打开 + const isOpen = widthThreshold || heightThreshold || + (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized); + + if (isOpen && !isDevToolsOpen) { + isDevToolsOpen = true; + + if (!warningShown) { + warningShown = true; + + // 清空控制台 console.clear(); + + // 显示警告页面 + const warningHTML = ` +
+
+ +

检测到开发者工具

+

+ 为保护系统安全,请关闭浏览器开发者工具后刷新页面 +

+ +

+ 如需使用开发者工具,请联系管理员开启调试模式 +

+
+
+ `; + + // 替换页面内容 + document.body.innerHTML = warningHTML; } - } else { + } else if (!isOpen) { isDevToolsOpen = false; } - }, 500); + } + + // 立即检测一次(页面加载时就检查) + checkDevTools(); + + // 定期检测 + setInterval(checkDevTools, 500); + + // 使用debugger语句检测(更灵敏) + setInterval(function() { + const before = new Date().getTime(); + debugger; // 如果开发者工具打开,这里会暂停 + const after = new Date().getTime(); + + // 如果暂停时间超过100ms,说明开发者工具打开了 + if (after - before > 100) { + checkDevTools(); + } + }, 1000); })(); }