怎样屏蔽别的开发人员调试你的代码

调试控制台

var ConsoleManager = {
    onOpen: function () {
        try {
            window.open("about:blank", target = "_self")
        } catch (e) {
            var n = document.createElement("button");
            n.onclick = function () {
                window.open("about:blank", target = "_self")
            }, n.click()
        }
    },
    onClose: function () {
        alert("Console is closed!!!!!")
    },
    init: function () {
        var e = this,
            n = document.createElement("div"),
            t = false,
            o = false;
        Object.defineProperty(n, "id", {
            get: function () {
                t || (e.onOpen(), t = !0), o = !0
            }
        }), setInterval(function () {
            o = !1, 
            console.info(n),//console.log/console.info等console.api只有在控制台打开才会执行而打印n即一个div,会调用这个dom对象的获取id的方法,因此达到打开空白页的方法
             console.clear(), 
             !o && t && (e.onClose(), t = !1)
        }, 200)
    }
};
ConsoleManager.init();

参考:

https://github.com/Netrvin/PageGuard.js

https://github.com/sindresorhus/devtools-detect

https://stackoverflow.com/quest

你可能感兴趣的:(怎样屏蔽别的开发人员调试你的代码)