当前位置:网站首页>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
边栏推荐
- Redis interview questions must be known and learned
- MySQL 为什么有时候会选错索引?
- 房地产数字化转型方案:全方位数智化系统运营,助力房企管控实效提升
- Which strings will be resolved to null by fastjason?
- 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
- Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
- ELK实时日志分析平台
- 关于软考高级要不要报班学习
- 二分、三分、01分数规划【第III弹】
- 二维前缀和
猜你喜欢

Redis面试题必知必会

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

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

深度学习必懂的 13 种概率分布

二分、三分、01分数规划 【第I弹】
![[esp32][esp idf] ap+sta realizes wireless bridging and transferring WiFi signals](/img/bf/0a968064a8f7c11b86a2a2820208e6.png)
[esp32][esp idf] ap+sta realizes wireless bridging and transferring WiFi signals

房地产数字化转型方案:全方位数智化系统运营,助力房企管控实效提升

OSPF expansion configuration, routing principles, anti ring and re release

图解 3 种主流企业架构模式(建议收藏!)

TCP Basics
随机推荐
二分、三分、01分数规划【第III弹】
OSPF的LSA及优化
office2013以上输入数学公式
How to get more marks in the game under the new economic model of Plato farm
Weekly report on July 27, 2022
Set of bus related concepts
Kubernetes
Several innovative economic models of platofarm have inspired the current metacosmic market
PHP connection MySQL native code
19. 删除链表的倒数第 N 个结点
为什么要考一级建造师,一建证书含金量有多高?
基于ModelArts续写最伟大的作品【玩转华为云】
选择供应商服务系统,是大健康产业企业迈向数字化转型的第一步
Etcd(高可用KV数据库)
OSPF的拓展配置,选路原则,防环及重发布
【MySQL】MySQL错误“ERROR 2006 (HY000):MySQL server has gone away”
How PHP gets the interface
Choosing a supplier service system is the first step for large health industry enterprises to move towards digital transformation
Digital transformation scheme of real estate: all-round digital intelligence system operation, helping real estate enterprises improve the effectiveness of management and control
【JZOF】15二进制中1的位数