zl程序教程

您现在的位置是:首页 >  Javascript

当前栏目

网站那些阻止F12所遗留的彩蛋

2023-04-18 15:57:17 时间

看到好看的网页或者样式时候,大家都会利用我们浏览器的F12,也就是开发人员调试利器这一功能,那么各位老表为了防止自己心爱的代码被偷,也是煞费苦心,给网站设置各种键码限制,网站上也就遗留了很多彩蛋,这也也是一个独特的风景,下面一同欣赏几款我见到过有趣的彩蛋吧。

娱乐跳转搞笑型

按下F12自动跳转为另外网页,再配上滑稽的动画,让人哭笑不得。

$(document).ready(function(){$(".galleryidpost").lightGallery({selector: ".yoniu-index-img",share: false,share: false,showThumbByDefault: false,autoplayControls: false});});
<script>
    ! function(e) {
        function n(e) {
            function n() {
                return u
            }

            function o() {
                window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized ? t("on") : (a = "off", console.log(d), console.clear(), t(a))
            }

            function t(e) {
                u !== e && (u = e, "function" == typeof c.onchange && c.onchange(e))
            }

            function r() {
                l || (l = !0, window.removeEventListener("resize", o), clearInterval(f))
            }
            "function" == typeof e && (e = {
                onchange: e
            });
            var i = (e = e || {}).delay || 500,
                c = {};
            c.onchange = e.onchange;
            var a, d = new Image;
            d.__defineGetter__("id", function() {
                a = "on"
            });
            var u = "unknown";
            c.getStatus = n;
            var f = setInterval(o, i);
            window.addEventListener("resize", o);
            var l;
            return c.free = r, c
        }
        var o = o || {};
        o.create = n, "function" == typeof define ? (define.amd || define.cmd) && define(function() {
            return o
        }) : "undefined" != typeof module && module.exports ? module.exports = o : window.jdetects = o
    }(), jdetects.create(function(e) {
        var a = 0;
        var n = setInterval(function() {
            if("on" == e) {
                setTimeout(function() {
                    if(a == 0) {
                        a = 1;
                        //此处改成你要跳转的地址
                        top.location.href = 'sb.html'
                    }
                }, 200)
            }
        }, 100)
    });
</script>

阻止键码气人型

F12键码为123,代码直接阻止了默认事件行为发生,点不开,气人。

<script>
    window.onkeydown = window.onkeyup = window.onkeypress = function(event) {
        if(event.keyCode = 123) {
            event.preventDefault();
            window.event.returnValue = false;
        }
    }
</script>

反调试刷新型

不要使用控制台输出的提醒,直接在页面输出提醒就好了。

<script>
    function endebug(off, code) {
        if(!off) {
            ! function(e) {
                function n(e) {
                    function n() {
                        return u
                    }

                    function o() {
                        window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized ? t("on") : (a = "off", console.log(d), console.clear(), t(a))
                    }

                    function t(e) {
                        u !== e && (u = e, "function" == typeof c.onchange && c.onchange(e))
                    }

                    function r() {
                        l || (l = !0, window.removeEventListener("resize", o), clearInterval(f))
                    }
                    "function" == typeof e && (e = {
                        onchange: e
                    });
                    var i = (e = e || {}).delay || 500,
                        c = {};
                    c.onchange = e.onchange;
                    var a, d = new Image;
                    d.__defineGetter__("id", function() {
                        a = "on"
                    });
                    var u = "unknown";
                    c.getStatus = n;
                    var f = setInterval(o, i);
                    window.addEventListener("resize", o);
                    var l;
                    return c.free = r, c
                }
                var o = o || {};
                o.create = n, "function" == typeof define ? (define.amd || define.cmd) && define(function() {
                    return o
                }) : "undefined" != typeof module && module.exports ? module.exports = o : window.jdetects = o
            }(), jdetects.create(function(e) {
                var a = 0;
                var n = setInterval(function() {
                    if("on" == e) {
                        setTimeout(function() {
                            if(a == 0) {
                                a = 1;
                                setTimeout(code);
                            }
                        }, 200)
                    }
                }, 100)
            })
        }
    }

    endebug(false, function() {

        document.write('<div style="text-align:center;color:red;font-size:30px;">检测到非法调试,请关闭后刷新重试</div>');
    });
</script>

Debugger恶心型

<script>
    var _0xde02 = ["length", "", "debugger", "constructor"];
    !(function test() {
        try {
            !(function _0x6ba3x2(_0x6ba3x3) {
                ((_0xde02[1] + _0x6ba3x3 / _0x6ba3x3)[_0xde02[0]] !== 1 || _0x6ba3x3 === 0) && function() {}
                [_0xde02[3]](_0xde02[2])(),
                _0x6ba3x2(++_0x6ba3x3)
            }(0))
        } catch(e) {
            setTimeout(test, 80)
        }
    }())
</script>