// 屏蔽右键菜单 document.addEventListener('contextmenu', function(e) { e.preventDefault(); return false; }); // 屏蔽 F12、Ctrl+U、Ctrl+Shift+I、Ctrl+B 等快捷键 document.addEventListener('keydown', function(e) { if ( e.key === 'F12' || // F12 e.keyCode === 123 || // F12 (兼容旧浏览器) (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.keyCode === 73)) || // Ctrl+Shift+I (e.ctrlKey && e.shiftKey && (e.key === 'J' || e.keyCode === 74)) || // Ctrl+Shift+J (e.ctrlKey && (e.key === 'U' || e.keyCode === 85)) || // Ctrl+U (e.ctrlKey && (e.key === 'B' || e.keyCode === 66)) || // Ctrl+B (e.key === 'ContextMenu' || e.keyCode === 93) // 菜单键 ) { e.preventDefault(); return false; } }); // 检测 DevTools 是否打开 (function() { let lastWidth = window.innerWidth; let lastHeight = window.innerHeight; const devToolsCheck = setInterval(() => { const width = window.innerWidth; const height = window.innerHeight; if (width !== lastWidth || height !== lastHeight) { console.log("检测到 DevTools 打开!"); try { window.location.href = "about:blank"; } catch (e) { setInterval(() => { debugger; }, 100); } clearInterval(devToolsCheck); } lastWidth = width; lastHeight = height; }, 100); })(); // 防止直接访问 view-source: if (window.location.href.startsWith("view-source:")) { window.location.href = "about:blank"; } |
本网声明:海南网发布此文仅出于信息分享,并非赞同其观点或证实其描述,不承担侵权行为的连带责任。文章内容仅供参考,不构成投资建议。投资者据此操作,风险自担。版权归原作者所有,如涉版权或来源标注有误,请联系我们删除。本网原创内容未经书面授权,任何单位或个人不得转载和摘编。
[ 编辑: NO 26 ]




