当前位置:网站首页>Prevent others from using the browser to debug

Prevent others from using the browser to debug

2022-06-23 00:44:00 Ziwei front end

var 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();
	        alert(' Do you want to see the code ?');
        } else {
            open = false;
        }
    }
})();

check.addListener(function () {
	window.location.reload();
});

原网站

版权声明
本文为[Ziwei front end]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206222049583327.html