准备文件

bancsl.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function forbidden_control() {
//通过判断窗口大小变化控制,不可靠(可以通过返回或者先开启控制台再打开网页的方式破解)
//手机端访问会出现问题,暂时不建议开启,等我先想想怎么解决
/*
let h = window.innerHeight;
let w = window.innerWidth;
window.onresize = function () {
if (h != window.innerHeight || w != window.innerWidth) {
window.close();
//此处可以自己定义跳转
//window.location = "/error/403.html";
window.location = "about:blank";
}
} */
//唐志远dalao no solutions以解决F12、右键事件
$.extend({
message: function(a) {
var b = {
title: "",
message: "操作成功",
time: "3000",
type: "success",
showClose: !0,
autoClose: !0,
onClose: function() {}
};
"string" == typeof a && (b.message = a), "object" == typeof a && (b = $.extend({}, b, a));
var c, d, e, f = b.showClose ? '<div class="c-message--close">×</div>' : "",
g = "" !== b.title ? '<h2 class="c-message__title">' + b.title + "</h2>" : "",
h = '<div class="c-message animated animated-lento slideInRight"><i class=" c-message--icon c-message--' + b.type + '"></i><div class="el-notification__group">' + g + '<div class="el-notification__content">' + b.message + "</div>" + f + "</div></div>",
i = $("body"),
j = $(h);
d = function() {
j.addClass("slideOutRight"), j.one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {
e()
})
}, e = function() {
j.remove(), b.onClose(b), clearTimeout(c)
}, $(".c-message").remove(), i.append(j), j.one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {
j.removeClass("messageFadeInDown")
}), i.on("click", ".c-message--close", function(a) {
d()
}), b.autoClose && (c = setTimeout(function() {
d()
}, b.time))
}
}),
document.onkeydown = function(e) {
if (123 == e.keyCode || e.ctrlKey && e.shiftKey && (74 === e.keyCode || 73 === e.keyCode || 67 === e.keyCode) || (e.ctrlKey && 85 === e.keyCode)) return $.message({
message: "采用本站js及css请注明来源,禁止商业使用!",
title: "不能使用shift+ctrl+i/f12打开控制台喔!",
type: "error",
autoHide: !1,
time: "3000"
}), event.keyCode = 0, event.returnValue = !1, !1
}, document.oncontextmenu = function() {
return $.message({
message: "采用本站js及css请注明来源,禁止商业使用!",
title: "不能使用右键哦!",
type: "error",
autoHide: !1,
time: "3000"
}), !1
}
}
//执行函数
forbidden_control()
//监控window.visualViewport的高度与宽度变化并无限debugger
var width = window.visualViewport.width;
var height = window.visualViewport.height;
setInterval(function () {
var new_width = window.visualViewport.width;
var new_height = window.visualViewport.height;
if(new_width<width||new_height<height){
eval('!function(){debugger}()')
}
},800)

jquery.min.js

下载站

可以url引用,也可以直接下载本地使用

function.min.css

下载链接

也可以直接在head中写入

1
<link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/tzy13755126023/BLOG_SOURCE/css/function.min.css">

使用

将上一步下载好的js、cs文件在head中引用,此处我是使用本地文件

1
2
3
<script src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bancsl.js"></script>
<link rel="stylesheet" href="/css/function.min.css"></script>

改进

还是那句话,会的人防不住,不会的人不用防。

在志远兄的原文中未为提到具体的使用方法,本文在此基础上对使用方法进行了补充并添加了其它的一些功能。
所有的代码和资源均来源网络,本文仅仅是一个小小的整合。如果大家有什么更好的建议,@欢迎交流学习~

参考

JS禁止右键和F12查看 by AlexTao

禁止右键及F12等事件 by 唐志远

浏览器F12(开发者工具DevTools)的屏蔽调用与绕过屏蔽 by Sh4d0w_小白