// 禁止按钮F12
document.onkeydown = function (event) {var ev = event || window.event || arguments.callee.caller.arguments[0];console.log(event.keyCode)if (event.keyCode === 123) {return false; //123 代表F12键位}
}
// 禁止右键
document.oncontextmenu = function (e) {e.preventDefault();
};function 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';window.location.href = 'about:blank'},offed: function () {// document.body.innerHTML = 'Dev Tools is off';}
});