This repository has been archived by the owner on Jul 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
source.html
99 lines (88 loc) · 2.49 KB
/
source.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
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>←_← →_→</title>
<link rel="shortcut icon" type="image/x-icon" href="laji.png">
<style>
body {
position: relative;
display: flex;
align-items: center;
justify-content: center;
cursor: url('laji.png'), default;
margin: 0;
}
.mouse {
position: absolute;
width: 30px;
height: 30px;
background: url('laji.png') center right no-repeat;
transition: transform 2s ease-in-out;
}
</style>
</head>
<body>
<script>
(() => {
const length = parseInt(_('n')) || 666
const timeout = parseInt(_('t')) || 50
const bgImg = _('b')
let height = 30
let width = 30
let index = 0
function _(key) {
let result = null
let tmp = []
location.search.substr(1).split('&').forEach(v => {
tmp = v.split('=')
if (tmp[0] === key) {
result = decodeURIComponent(tmp[1])
}
})
return result
}
function update(element) {
const cW = document.body.clientWidth / 2 - width / 2
const cH = document.body.clientHeight / 2 - height / 2
const mL = Math.floor(Math.random() * (cW * 2 + 1) - cW)
const mT = Math.floor(Math.random() * (cH * 2 + 1) - cH)
element.style.transform = `translate(${mL}px, ${mT}px)`
}
if (bgImg) {
const img = new Image()
img.src = bgImg
img.onload = () => {
const style = document.createElement('style')
width = img.width
height = img.height
style.textContent = `
body {
cursor: url(${bgImg}), default;
}
.mouse {
width: ${width}px;
height: ${height}px;
background-image: url(${bgImg});
}
`
document.head.appendChild(style)
}
}
for (; index < length; index++) {
const $mouse = document.createElement('div')
$mouse.classList = 'mouse'
$mouse.style.transitionDelay = `${index * 25}ms`
$mouse.addEventListener('transitionend', () => {
update($mouse)
}, false)
setTimeout(() => {
document.body.appendChild($mouse)
update($mouse)
}, index * timeout)
}
})()
</script>
</body>
</html>