禁用开发者工具 禁用 f12 功能 禁右键 网站防扒等常用代码

2022-06-07 0 3,489

PS

禁用开发者工具 禁用 f12 功能 禁右键 网站防扒

禁用开发者工具 禁用 f12 功能 禁右键 网站防扒等常用代码

代码引入头部html标签

<script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js'></script>

其他代码



var h = window.innerHeight,w=window.innerWidth;
//禁用右键 (防止右键查看源代码)
window.οncοntextmenu=function(){return false;}
//在本网页的任何键盘敲击事件都是无效操作 (防止F12和shift+ctrl+i调起开发者工具)
window.onkeydown = window.onkeyup = window.onkeypress = function () {
    window.event.returnValue = false;
    return false;
}
//如果用户在工具栏调起开发者工具,那么判断浏览器的可视高度和可视宽度是否有改变,如有改变则关闭本页面
window.onresize = function () {
    if (h != window.innerHeight||w!=window.innerWidth){
        window.close();
        window.location = "about:blank";
    }
};

//debug调试时跳转页面
// var element = new Image();
// Object.defineProperty(element, 'id', {
//     get: function () {

//         var total = "";
//         for (var i = 0; i < 1000000; i++) {
//             total = total + i.toString();
//             history.pushState(0, 0, total);
//         } //死机代码
//         location.href = "//attch.tcdn.top/404.html"; //跳转网站
//         //   xyplay.echo("<br><br><br>检测到非法调试,请关闭后刷新重试!"); //用户窗口显示信息
//         setInterval("debugger;console.log(\'请勿非法调试,请联系QQ:1663115160\');"); //调试窗口显示信息

//         window.location.href = "//attch.tcdn.top/404.html"

//     }
// });

// setInterval(function () {
//     check();
// }, 2000);
// var check = function () {
//     function doCheck(a) {
//         if (('' + a / a)['length'] !== 1 || a % 20 === 0) {
//             (function () {} ['constructor']('debugger')());
//         } else {
//             (function () {} ['constructor']('debugger')());
//         }
//         doCheck(++a);
//     }
//     try {
//         doCheck(0);
//     } catch (err) {}
// };
// check();
// ((function () {
//     var callbacks = [],
//         timeLimit = 50,
//         open = false;
//     setInterval(loop, 1);
//     return {
//         addListener: function (fn) {
//             callbacks.push(fn);
//         },
//         cancleListenr: function (fn) {
//             callbacks = callbacks.filter(function (v) {
//                 return v !== fn;
//             });
//         }
//     }
//     function loop() {
//         var startTime = new Date();
//         debugger;
//         if (new Date() - startTime > timeLimit) {
//             if (!open) {
//                 callbacks.forEach(function (fn) {
//                     fn.call(null);
//                 });
//             }
//             open = true;
//             window.stop();
//             window.close();
//             // alert('警告:请不要打开浏览器调试模式,否则网页无法正常工作!');
//             document.body.innerHTML = "";
//         } else {
//             open = false;
//         }
//     }
// })()).addListener(function () {
//     window.location.reload();
// });


document.onkeydown = function () {
    var e = window.event || arguments[0];
    if ((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
        //ctrl + shift + i

        return false;
    }
}


// 禁止图片拖放
document.ondragstart = function () {
    return false
};
// 禁止选择文本
// document.onselectstart = function () {
//     if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type !=
//         "password") return false;
//     else return true;
// };
// if (window.sidebar) {
//     document.onmousedown = function (e) {
//         var obj = e.target;
//         if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() ==
//             "PASSWORD") return true;
//         else return false;
//     }
// };
// 禁止frame标签引用
if (parent.frames.length > 0) top.location.replace(document.location);



//屏蔽右键菜单
document.oncontextmenu = function (event) {
    if (window.event) {
        event = window.event;
    }
    try {
        var the = event.srcElement;
        if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
            return false;
        }
        return true;
    } catch (e) {
        return false;
    }
}
//屏蔽粘贴
document.onpaste = function (event) {
    if (window.event) {
        event = window.event;
    }
    try {
        var the = event.srcElement;
        if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
            return false;
        }
        return true;
    } catch (e) {
        return false;
    }
}
//屏蔽复制

//屏蔽剪切
document.oncut = function (event) {
    if (window.event) {
        event = window.event;
    }
    try {
        var the = event.srcElement;
        if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
            return false;
        }
        return true;
    } catch (e) {
        return false;
    }
}




//禁止f12

function fuckyou() {
    window.close(); //关闭当前窗口(防抽)
    window.location = "about:blank"; //将当前窗口跳转置空白页
}
//禁止Ctrl+U
var arr = [123, 17, 18];
document.oncontextmenu = new Function("event.returnValue=false;"), //禁用右键

    window.onkeydown = function (e) {
        var keyCode = e.keyCode || e.which || e.charCode;
        var ctrlKey = e.ctrlKey || e.metaKey;
        if (ctrlKey && keyCode == 85) {
            e.preventDefault();
        }
        if (arr.indexOf(keyCode) > -1) {
            e.preventDefault();
        }
    }

function ck() {
    console.profile();
    console.profileEnd();
    //我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!!
    if (console.clear) {
        console.clear()
    };
    if (typeof console.profiles == "object") {
        return console.profiles.length > 0;
    }
}

声明:本站所有资源仅供学习和研究传播,大家请在下载后24小时内删除,一切关于该资源商业行为与念破网(https://www.nianpo.com)无关。 请勿将该资源进行商业交易、转载等行为,该资源只为研究、学习所提供,该软件使用后发生的一切问题与本站无关。 (若您进入本站就表示同意以上条款)若本资源侵犯了您的权益,请联系我们予以删除!(E-mail:765934@qq.com) 会员QQ群:5676140

念破网 网络教程 禁用开发者工具 禁用 f12 功能 禁右键 网站防扒等常用代码 https://www.nianpo.com/355.html

常见问题

相关文章

官方客服团队

为您解决烦忧 - 24小时在线 专业服务