当前位置:网站首页>Talk about the problem of preventing others from debugging websites through console based on JS implementation
Talk about the problem of preventing others from debugging websites through console based on JS implementation
2022-07-28 10:11:00 【InfoQ】
Preface
- F12
- Right click ==》 Check
- browser ==》 More tools ==》 Developer tools ( Shortcut key :ctrl+shift+i)
Prevent opening the console
prevent F12 event
window.onkeydown = window.onkeyup = window.onkeypress = function (event) {
// Determine whether to press F12,F12 The key code is 123
if (event.keyCode = 123) {
event.preventDefault() // Prevent default event behavior
window.event.returnValue = false
}
}

Block right click events
oncontextmenuwindow.oncontextmenu = function() {
event.preventDefault() // Prevent default event behavior
return false
}

JS Operation console
browser ==》 More tools ==》 Developer tools ( Shortcut key :ctrl+shift+i)Regularly check browser window changes
let threshold = 160 // Open the wide or high threshold of the console
window.setInterval(function() {
if (window.outerWidth - window.innerWidth > threshold ||
window.outerHeight - window.innerHeight > threshold) {
// If you open the console , Then refresh the page
window.location.reload()
}
}, 1000)

Open the console pop-up window , Enable debugging debug debugging
debuggerdebuggerdebuggerThe first one is debug debugging
setInterval(function() {
check()
}, 1000);
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();

The second kind debug debugging
if(window.location.href.indexOf('#debug')==-1){
setInterval(function(){
(function (a) {return (function (a) {return (Function('Function(arguments[0]+"' + a + '")()'))})(a)})('bugger')('de', 0, 0, (0, 0))
}, 1000)
}

Open the console prompt ( Jump can be realized url Or refresh )
function toDevtools(){
let num = 0
var devtools = new Date()
devtools.toString = function() {
num++;
if(num>0){
alert(' The console is open ')
// You can write the logic of refresh or jump
}
}
console.log(devtools);
}
toDevtools()

Postscript
边栏推荐
- How PHP gets the interface
- ASP. Net core 6 framework unveiling example demonstration [29]: building a file server
- Arthas tutorial
- Platofarm has made continuous progress, and has launched the official version and super primitive NFT successively
- 网易笔试之不要二——欧式距离的典型应用
- [esp32][esp idf] esp32s3 quickly build lvglv7.9
- Redis interview questions must be known and learned
- (十)defer关键字
- 【MySQL】查询多个ID返回字符串拼接
- [openharmony] [rk2206] build openharmony compiler (2)
猜你喜欢

B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement
![[learning notes] border and period](/img/a4/5493f7eefc7dd0e38bc9a53a92b87b.png)
[learning notes] border and period

关于软考高级要不要报班学习

为什么要考一级建造师,一建证书含金量有多高?

Seektiger eco pass STI new progress, log in to ZB on April 14

Redis interview questions must be known and learned

Boss: there are too many systems in the company. Can we realize account interworking?

office2013以上输入数学公式

语音聊天app——如何规范开发流程?

我用小程序容器让移动研发效率提升了5倍!
随机推荐
LinkedList source massage, ah comfortable
Judge whether the string is palindrome
[ESP32][esp-idf][LVGL7.9] 使用oled iic编译失败
13 probability distributions that must be understood in deep learning
Flink - checkpoint Failure reason: Not all required tasks are currently running
Set of bus related concepts
Today, I want to talk about the data types of MySQL database
【学习笔记】border与period
Thinking and summary of technical personnel | R & D Efficiency
[ESP32][esp-idf] AP+STA实现无线桥接 中转wifi信号
海量数据TopN问题
ASP.NET Core 6框架揭秘实例演示[29]:搭建文件服务器
CloudCompare&PCL 匹配点采样一致性抑制
[openharmony] [rk2206] build openharmony compiler (2)
Edge team explains how to improve the comprehensive performance experience through disk cache compression technology
安装gmp
PHP Basics
SQL server, MySQL master-slave construction, EF core read-write separation code implementation
【FPGA教程案例41】图像案例1——通过verilog读取图片
Several innovative economic models of platofarm have inspired the current metacosmic market