-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.html
121 lines (111 loc) · 3.49 KB
/
index.html
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AutoMihoyoBBS验证码</title>
<style>
body {
margin: 50px 0;
text-align: center;
font-family: "PingFangSC-Regular", "Open Sans", Arial, "Hiragino Sans GB", "Microsoft YaHei", "STHeiti", "WenQuanYi Micro Hei", SimSun, sans-serif;
}
.inp {
border: 1px solid #cccccc;
border-radius: 2px;
padding: 0 10px;
width: 278px;
height: 40px;
font-size: 18px;
}
.btn {
border: 1px solid #cccccc;
border-radius: 2px;
width: 100px;
height: 40px;
font-size: 16px;
color: #666;
cursor: pointer;
background: white linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
}
.btn:hover {
background: white linear-gradient(0deg, #ffffff 0%, #f3f3f3 100%)
}
#captcha {
width: 300px;
display: inline-block;
}
.show {
display: block;
}
.hide {
display: none;
}
#notice {
color: red;
}
label {
vertical-align: top;
display: inline-block;
width: 80px;
text-align: right;
}
#wait {
text-align: left;
color: #666;
margin: 0;
}
</style>
</head>
<body>
<div>
<label>完成验证:</label>
<div id="captcha">
<p id="wait" class="show">正在加载验证码......</p>
</div>
</div>
<!-- 引入 极验官方gt.js,使用其中提供的 initGeetest 初始化函数 -->
<script src="https://static.geetest.com/static/js/gt.0.4.9.js"></script>
<script>
var handler = function (captchaObj) {
captchaObj.appendTo("#captcha");
captchaObj.onReady(function () {
document.getElementById("wait").style.display='none';
});
console.warn(1)
//拿到验证完的返回之后送回后端
captchaObj.onSuccess(function (){
var xhr = new XMLHttpRequest();
xhr.open("POST", "complete", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
alert("验证完成!请返回AutoMihoyoBBS。本页面即将关闭")
window.close()
}
};
xhr.send(JSON.stringify(captchaObj.getValidate()));
console.warn(2)
})
};
//从后端获取challenge并初始化验证码区域
var xhr = new XMLHttpRequest();
xhr.open("POST", "getChallenge", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var dataObj = JSON.parse(xhr.responseText);
initGeetest({
gt: dataObj.gt,
challenge: dataObj.challenge,
new_captcha:true,
offline: false,
product: "float",
width: "100%"
}, handler);
}
};
xhr.send("");
</script>
</body>
</html>