-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
554 lines (468 loc) · 16 KB
/
Copy pathindex.html
File metadata and controls
554 lines (468 loc) · 16 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>西西弗斯验证码</title>
<style>
:root {
--blue-primary: #4A90E2;
--bg-gray: #f9f9f9;
}
body {
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
background-color: #e9e9e9;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
/* 验证码外框 */
.captcha-container {
width: 350px;
background: white;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
border: 1px solid #ccc;
user-select: none;
position: relative;
}
/* 蓝色头部 */
.header {
background-color: var(--blue-primary);
color: white;
padding: 24px;
}
.header .title-small { font-size: 14px; margin-bottom: 4px; opacity: 0.9; }
.header .title-large { font-size: 24px; font-weight: bold; line-height: 1.2; }
/* 游戏内容区 */
.game-area {
height: 300px;
background-image: url('Background.png');
background-size: cover;
background-position: bottom left;
position: relative;
overflow: hidden;
}
/* 石头 */
#stone {
width: 50px;
height: 50px;
position: absolute;
background-image: url('Stone.png');
background-size: contain;
background-repeat: no-repeat;
transform-origin: center center;
bottom: 10px;
left: -60px;
}
/* 西西弗斯 */
#sisyphus {
width: 30px;
height: 60px;
position: absolute;
background-image: url('Sisyphus.png');
background-size: contain;
background-repeat: no-repeat;
bottom: 10px;
left: 10px;
}
/* 底部滑块容器 */
.slider-container {
height: 40px;
background-color: #f0f0f0;
border-top: 1px solid #eee;
position: relative;
touch-action: none;
}
/* 滑块轨道 */
.slider-track {
position: absolute;
top: 50%;
left: 10px;
right: 10px;
height: 10px;
background-color: #d0d0d0;
transform: translateY(-50%);
border-radius: 5px;
}
/* 滑块把手 */
.slider-handle {
width: 40px;
height: 40px;
background-color: var(--blue-primary);
border-radius: 50%;
position: absolute;
top: 0;
left: 10px; /* 留在安全区内 */
cursor: grab;
transition: transform 0.1s ease-out;
z-index: 10;
}
.slider-handle.dragging {
cursor: grabbing;
transform: scale(1.1);
}
/* 底部工具栏 */
.footer {
border-top: 1px solid #eee;
padding: 10px 15px;
display: flex;
justify-content: space-between;
align-items: center;
}
.icons { display: flex; gap: 15px; color: #777; font-size: 20px; }
.icons span { cursor: pointer; }
.verify-btn {
background-color: var(--blue-primary);
color: white;
border: none;
padding: 10px 20px;
font-weight: bold;
border-radius: 3px;
cursor: pointer;
text-transform: uppercase;
transition: background 0.2s;
}
.verify-btn:active { background-color: #357abd; }
/* 结算弹窗 */
#status-overlay {
display: none;
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.8);
color: white;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
z-index: 100;
}
#result-desc { max-width: 80%; line-height: 1.5; }
/* 关于界面 */
#about-box {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 280px;
background: white;
padding: 20px;
box-shadow: 0 0 15px rgba(0,0,0,0.1);
border: 1px solid #dcdcdc;
z-index: 1000;
animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
from { opacity: 0; transform: translate(-50%, -45%) scale(0.95); }
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.about-header {
font-size: 14px;
font-weight: 500;
color: #555;
margin-bottom: 12px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.about-body {
font-size: 13px;
line-height: 1.5;
color: #777;
border-top: 1px solid #f1f1f1;
padding-top: 12px;
}
.about-body a {
color: var(--blue-primary);
text-decoration: none;
}
.about-body a:hover {
text-decoration: underline;
}
/* 按钮 */
.about-close-btn {
display: block;
width: fit-content;
margin: 15px 0 0 auto; /* 右对齐,类 Google 布局 */
background-color: var(--blue-primary);
color: white;
border: none;
padding: 8px 16px;
border-radius: 0px; /* 直角 */
cursor: pointer;
font-size: 13px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="captcha-container">
<div class="header">
<div class="title-small">拖动滑块,推石上山</div>
<div class="title-large">西西弗斯验证码</div>
<div class="title-small" style="margin-top:10px;">日复一日,永无止境</div>
</div>
<audio id="bg-music" loop>
<source src="Background.mp3" type="audio/mpeg">
您的浏览器不支持音频播放
</audio>
<div id="about-box">
<div class="about-header">About</div>
<div class="about-body">
<strong style="color: #333;">无尽的努力,荒诞的命运。</strong><br><br>
西西弗斯被判处永无止境地推石上山,这是一场关于“徒劳”的交互实验。
在这里,巨石滑落不再是失败,而是反抗的开始。<br><br>
<small style="color:#888; font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;">
<b>致谢:</b> <a href="https://github.com/CS-LX" target="_blank">CS-LX</a> [原项目作者 & 灵感提供]<br>
<b>维护:</b> <a href="https://github.com/HSSkyBoy" target="_blank"><b>NkBe</b></a>, <a href="https://github.com/mrmiaomrzh" target="_blank"><b>Mrmiaomrzh</b></a><br>
<b>技术实现:</b> 原生 JS / CSS3 物理模拟<br>
</small>
<hr style="border:none; border-top:1px solid #f5f5f5; margin:15px 0;">
<i style="color:#aaa; display:block; text-align:center; font-size: 12px;">「我们必须想像西西弗斯是幸福的」</i>
</div>
<button class="about-close-btn" onclick="toggleAbout(false)">了解</button>
</div>
<div class="game-area">
<div id="sisyphus"></div>
<div id="stone"></div>
</div>
<div class="slider-container">
<div class="slider-track"></div>
<div class="slider-handle" id="slider-handle"></div>
</div>
<div class="footer">
<div class="icons">
<span onclick="initGame()">🔄</span>
<span id="music-btn" onclick="toggleMusic()">🎧</span>
<span onclick="toggleAbout(true)">ⓘ</span>
</div>
<button class="verify-btn" id="verify-btn" onclick="verify()">验证</button>
</div>
</div>
<div id="status-overlay">
<h2 id="result-title">验证失败</h2>
<p id="result-desc"></p>
<button id="result-btn" onclick="closeOverlay()" style="padding: 10px 20px; margin-top: 20px; cursor: pointer;">再次尝试</button>
</div>
<script>
const Config = {
slopeFactor: 0.5,
gravityNormal: 0.4,
gravityTop: 1.14, // 接近山顶时的重力阻力
slipPenalty: 0.3, // 接近山顶时哪怕按住也会随机滑落的惩罚值
successThreshold: 95 // 到达此进度算作"在山顶"
};
const GameState = {
value: 0.0,
isDragging: false,
hasMoved: false, // 记录是否操作过
hasReachedTop: false, // 记录是否曾到达过山顶
rafId: null
};
// DOM 元素引用
const el = {
container: document.querySelector('.captcha-container'),
game: document.querySelector('.game-area'),
stone: document.getElementById('stone'),
sisyphus: document.getElementById('sisyphus'),
handle: document.getElementById('slider-handle'),
overlay: document.getElementById('status-overlay')
};
let layout = {};
/* ---------- 初始化 ---------- */
function measure() {
const HORIZONTAL_PADDING = 20;
const HANDLE_WIDTH = 40;
layout = {
width: el.container.offsetWidth,
gameW: el.game.offsetWidth,
gameH: el.game.offsetHeight,
sliderMax: el.container.offsetWidth - HORIZONTAL_PADDING - HANDLE_WIDTH
};
}
function initGame() {
GameState.value = 0;
GameState.isDragging = false;
GameState.hasMoved = false;
GameState.hasReachedTop = false;
if (GameState.rafId) cancelAnimationFrame(GameState.rafId);
el.handle.classList.remove('dragging');
closeOverlay();
measure();
render();
loop();
}
window.addEventListener('resize', measure);
function toggleAbout(show) {
const box = document.getElementById('about-box');
box.style.display = show ? 'block' : 'none';
if (show) {
GameState.isDragging = false;
el.handle.classList.remove('dragging');
}
}
/* ---------- 渲染机制 ---------- */
function render() {
const v = GameState.value;
// 滑块位置
const x = (v / 100) * layout.sliderMax;
el.handle.style.transform = `translateX(${x}px)`;
// 西西弗斯位置
const sx = 10 + (v / 100) * (layout.gameW - 50);
const sy = 10 + (v / 40) * (layout.gameH - 50) * Config.slopeFactor;
el.sisyphus.style.left = sx + 'px';
el.sisyphus.style.bottom = sy + 'px';
// 石头位置跟随西西弗斯,增加滚动角度
const stoneX = sx + 15;
const stoneY = sy + 40;
el.stone.style.left = stoneX + 'px';
el.stone.style.bottom = stoneY + 'px';
el.stone.style.transform = `rotate(${v * 10.8}deg)`;
}
/* ---------- 物理逻辑 ---------- */
function updatePhysics() {
// 获取音频对象
const music = document.getElementById('bg-music');
// 状态机更新
if (GameState.value >= Config.successThreshold) {
GameState.hasReachedTop = true;
}
if (GameState.isDragging) {
if (music) music.playbackRate = 1.0;
if (GameState.value > 87 && Math.random() < 0.07 ) {
GameState.value -= Config.slipPenalty;
}
return; toggleMusic
}
// 溜车逻辑
if (GameState.value > 0) {
const gravity = GameState.value > 87 ? Config.gravityTop : Config.gravityNormal;
GameState.value -= gravity;
if (music && !music.paused) {
music.playbackRate = 2.0;
}
} else {
if (music) music.playbackRate = 1.0;
}
// 边界安全
GameState.value = Math.max(0, Math.min(101, GameState.value));
}
/* ---------- 主循环 ---------- */
function loop() {
updatePhysics();
render();
GameState.rafId = requestAnimationFrame(loop);
}
/* ---------- 交互层 ---------- */
let lastX = 0;
el.handle.addEventListener('pointerdown', e => {
GameState.isDragging = true;
GameState.hasMoved = true;
el.handle.classList.add('dragging');
lastX = e.clientX;
el.handle.setPointerCapture(e.pointerId);
});
el.handle.addEventListener('pointermove', e => {
if (!GameState.isDragging) return;
const dx = e.clientX - lastX;
lastX = e.clientX;
GameState.value += (dx / layout.sliderMax) * 100;
GameState.value = Math.max(0, Math.min(100, GameState.value));
});
el.handle.addEventListener('pointerup', () => {
GameState.isDragging = false;
el.handle.classList.remove('dragging');
});
/* ---------- 核心逻辑 ---------- */
function checkGameStatus() {
const { value, hasMoved, hasReachedTop } = GameState;
// 完全沒動過
if (!hasMoved) return 'UNMOVED';
// 成功到頂,並且穩在頂部
if (hasReachedTop && value >= Config.successThreshold) return 'SUCCESS';
// 曾經到過頂,但最後滑塊完全退回原點 (進度為 0)
if (value === 0) return 'HELPLESS';
// 曾經到過頂,但正在滾落 (進度大於 0)
if (hasReachedTop && value < Config.successThreshold) return 'DESPAIR';
// 動過,但從未到達過山頂
return 'MOCKED';
}
function verify() {
const status = checkGameStatus();
const targetUrl = "https://www.bilibili.com/video/BV12SoeYdEH8/";
switch (status) {
case 'UNMOVED':
showResult(
"毫无作为",
"石头不会自己飞上山,你甚至连推都不愿意推一下。"
);
break;
case 'MOCKED':
showResult(
"半途而废",
"你连山顶的风景都没见过就放弃了,这是非西西弗斯的行为。"
);
break;
case 'HELPLESS':
showResult(
"深深的无力",
"努力过,挣扎过,最后却还是回到了原点,只剩下一声叹息。"
);
break;
case 'DESPAIR':
showResult(
"西西弗斯式的绝望",
"眼看已抵山顶,却只能眼睁睁看着巨石滚落谷底。这才是真正的荒诞。"
);
break;
case 'SUCCESS':
showResult(
"驗證成功",
"誰能想到,西西弗斯真的能把巨石永遠釘在山頂!你戰勝了作者設下的無盡折磨,擺脫了滾落的宿命,這波,你贏麻了!",
"前往終點",
() => window.location.href = targetUrl // 點擊跳轉指定URL
);
break;
}
}
/* ---------- 音频控制 ---------- */
let isPlaying = false;
const music = document.getElementById('bg-music');
const musicBtn = document.getElementById('music-btn');
function toggleMusic() {
if (isPlaying) {
music.pause();
musicBtn.style.color = '#777';
musicBtn.style.textShadow = 'none';
} else {
music.play().catch(err => {
});
musicBtn.style.color = 'var(--blue-primary)';
musicBtn.style.textShadow = '0 0 10px var(--blue-primary), 0 0 20px var(--blue-primary)';
}
isPlaying = !isPlaying;
}
/* ---------- UI ---------- */
function showResult(title, desc, btnText = "再次嘗試", btnAction = closeOverlay) {
const resultTitle = document.getElementById('result-title');
const resultDesc = document.getElementById('result-desc');
const resultBtn = document.getElementById('result-btn');
resultBtn.innerText = btnText;
resultBtn.onclick = btnAction;
resultTitle.innerText = title;
resultDesc.innerText = desc;
el.overlay.style.display = 'flex';
}
function closeOverlay() {
el.overlay.style.display = 'none';
initGame();
}
function closeOverlay() {
el.overlay.style.display = 'none';
}
/* ---------- 啟動 ---------- */
initGame();
</script>
</body>
</html>