当前位置:网站首页>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
边栏推荐
- Digital transformation scheme of real estate: all-round digital intelligence system operation, helping real estate enterprises improve the effectiveness of management and control
- uni-app进阶之创建组件/原生渲染
- ASP.NET Core 6框架揭秘实例演示[29]:搭建文件服务器
- 基于ModelArts续写最伟大的作品【玩转华为云】
- 19. 删除链表的倒数第 N 个结点
- 02.1.2.逻辑类型 bool
- 【MySQL】Got an error reading communication packets
- 【MySQL】查询多个ID返回字符串拼接
- OSPF expansion configuration, routing principles, anti ring and re release
- (十)defer关键字
猜你喜欢

高温天气筑牢安全生产防线,广州海珠区开展加油站应急演练

arthas使用教程

Digital transformation scheme of real estate: all-round digital intelligence system operation, helping real estate enterprises improve the effectiveness of management and control

关于软考高级要不要报班学习
JWT 登录认证 + Token 自动续期方案,写得太好了!
![[learning notes] border and period](/img/a4/5493f7eefc7dd0e38bc9a53a92b87b.png)
[learning notes] border and period

LSA and optimization of OSPF
![[ESP32][esp-idf] esp32s3快速搭建LVGLV7.9](/img/39/8efef047d0a9223b97819a54b5edf8.png)
[ESP32][esp-idf] esp32s3快速搭建LVGLV7.9

【JS高级】js之函数、重载、匿名函数、作用域及作用域链_03

The blind box of super primitive series will be launched soon, and platofarm will enable more rights and interests
随机推荐
Redis面试题必知必会
[OpenHarmony] [RK2206] 构建OpenHarmony编译器 (二)
2021.07.13 我们是这样崩的
Plato farm - a farm meta universe game with Plato as the goal
19. 删除链表的倒数第 N 个结点
【FPGA教程案例41】图像案例1——通过verilog读取图片
医药行业数字化建设,箭在弦上
【云驻共创】企业数字化转型,华为云咨询与你同行
Guangzhou metro line 14 xinshixu station is under construction, and residents in Baiyun District are about to start a double line transfer mode!
Prometheus 运维工具 Promtool (四)TSDB 功能
Arthas tutorial
Read Plato farm's eplato and the reason for its high premium
Cloudcompare & PCL matching point sampling consistency suppression
【JZOF】15二进制中1的位数
SQL server, MySQL master-slave construction, EF core read-write separation code implementation
Redis interview questions must be known and learned
我用小程序容器让移动研发效率提升了5倍!
What are the advantages of MRO purchasing website for industrial products? One article will help you understand
Kubernetes
关于软考高级要不要报班学习