-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestricted-interceptor.html
More file actions
88 lines (86 loc) · 2.63 KB
/
restricted-interceptor.html
File metadata and controls
88 lines (86 loc) · 2.63 KB
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
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>限制级内容拦截器</title>
<style>
.input-date-birthday-class,.btn-submit-class {
border-radius: 23px;
border: 1px solid #dfe1e5;
padding: 6px;
}
.ahref-after{
font-weight: lighter;
font-size: 68%;
margin-top: .4rem;
}
hr {
margin: 1em 2em;
padding: 0;
height: 1px;
border: none;
color: #555545;
color: #DDD;
background-color: #AAA;
background-color: #555545;
}
a {text-decoration: none;}
</style>
</head>
<body style="text-align: center;">
<noscript>
你的浏览器可能不支持JavaScript,此程序必须使用JavaScript执行!
</noscript>
<input type="date" name="input-date-birthday" id="input-date-birthday" class="input-date-birthday-class" placeholder="请输入出生日期(例如:2000/01/01)">
<button class="btn-submit-class" onclick="checkAge()">验证</button>
<br><hr>
<div class="ahref-after">
若继续使用则代表你同意相关规则。本程序不会收集任何日志,所有信息亦在本地处理和使用。
</div>
<script>
function getQueryString(linkurl) {
var query_string = window.location.search;
if (!query_string) return null; // 如果无参,返回null
var re = /[?&]?([^=]+)=([^&]*)/g;
var tokens;
while (tokens = re.exec(query_string)) {
if (decodeURIComponent(tokens[1]) === linkurl) {
return decodeURIComponent(tokens[2]);
}
}
return null;
}
var link = getQueryString('linkurl');
function checkAge() {
var birthday = document.getElementById("input-date-birthday").value;
var regExp = /^(\d{4})[\/|-](\d{1,2})[\/|-](\d{1,2})$/;
if (!regExp.test(birthday)) {
alert("你输入的出生日期格式不正确,请尝试重新输入。");
return false;
}
var age = getAge(birthday);
if (isNaN(age)) {
alert("你输入的出生日期信息无效,请尝试重新输入。");
return false;
}
if (age < 18) {
alert("你的年龄未满18周岁,无法访问限制级页面。");
return false;
}
window.top.location.href=link+"#u-rated";
window.parent.location.href=link+"#u-rated";
window.top.location.replace(link+"#u-rated");
}
function getAge(dateString) {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
</script>
</body>
</html>