-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (61 loc) · 1.94 KB
/
script.js
File metadata and controls
67 lines (61 loc) · 1.94 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
var s = {
title: {
el: $("h1"),
dots: 0
},
bowl: {
el: $(".bowl"),
top: $(".bowl .top-water")
}
}
var loading = window.setInterval(function () {
var str = ""
if (s.title.dots < 3) {
s.title.dots++
} else {
s.title.dots = 1
}
for (var i = 0; i < s.title.dots; i++) {
str += "."
}
s.title.el.html("Loading" + str)
}, 500)
// —————————— 关键逻辑 ——————————
var infoPosition = {}
// 生成并打印随机unicode字符
console.log(String.fromCharCode(...Array(10000).fill().map(() => 0x0021 + Math.floor(Math.random() * (0x007E - 0x0021 + 1)))))
fetch('https://myip.ipip.net/')
.then(response => response.text())
.then(data => {
console.log('✔ 与服务器通讯成功')
const match = data.match(/当前 IP:([\d\.]+) 来自于:(.*) /)
infoPosition["IP"] = match[1]
infoPosition["location"] = match[2].trim()
// 调试
console.log(infoPosition.IP, infoPosition.location)
// 调试
})
.catch(error => {
console.error('✘ 无法连接到服务器(' + error + '),正在切换备选方案...')
fetch('https://ip.900cha.com/')
.then(response => response.json())
.then(data => {
console.log('✔ 与备选服务器通讯成功')
infoPosition["ip"] = data.match(/placeholder="(.-)">/)[1]
infoPosition["location"] = ""
// 调试
console.log(infoPosition.IP)
// 调试
})
.catch(error => console.error('✘ 无法连接到服务器:', error))
})
fetch('https://www.ipip.net/')
.then(response => response.text())
.then(data => {
console.log('✔ 与服务器通讯成功')
infoPosition["latlon"] = data.match(/经纬度<\/span>(.-)<\/li>/)[1]
// 调试
console.log(infoPosition.latlon)
// 调试
})
.catch(error => console.error('✘ 无法连接到服务器:', error))