Created
May 14, 2025 02:05
-
-
Save tranchausky/b6b6b55457a8f0632f5017b13ebebe9d to your computer and use it in GitHub Desktop.
block dev tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//nq57.mst.gov.vn | |
function isDeveloperToolsShortcut(e) { | |
const isF12 = e.key === "F12"; | |
const isCtrlShiftKeyCombo = (e.ctrlKey || e.metaKey) && e.shiftKey && ["I", "J", "C"].includes(e.key); | |
const isCtrlU = (e.ctrlKey || e.metaKey) && e.keyCode === 85; | |
return isF12 || isCtrlShiftKeyCombo || isCtrlU; | |
} | |
function isMobileDevice() { | |
if (navigator.userAgentData) { | |
return navigator.userAgentData.mobile; | |
} | |
return /iPad|iPhone|iPod|Android/.test(navigator.userAgent); | |
} | |
document.addEventListener("keydown", function (e) { | |
if (isDeveloperToolsShortcut(e)) { | |
e.preventDefault(); | |
// alert("Không được phép truy cập Developer Tools."); | |
} | |
}); | |
document.addEventListener("contextmenu", function (e) { | |
if (!isMobileDevice() && navigator.platform.includes("Win")) { | |
e.preventDefault(); | |
// alert("Chuột phải bị vô hiệu hóa."); | |
} | |
}); | |
let devToolsOpen = false; | |
const threshold = 160; | |
setInterval(function () { | |
if (!isMobileDevice()) { | |
const isOpen = window.outerWidth - window.innerWidth > threshold || window.outerHeight - window.innerHeight > threshold; | |
if (isOpen && !devToolsOpen) { | |
devToolsOpen = true; | |
// alert("Developer Tools được phát hiện! Mã nguồn đã bị xóa."); | |
document.body.innerHTML = "<h1>Phát hiện mở Developer Tools. Trang đã bị xóa.</h1>"; | |
} else if (!isOpen) { | |
devToolsOpen = false; | |
} | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment