Skip to content

Commit ee15ea8

Browse files
committed
add:扫码插件
1 parent 5b6ec5b commit ee15ea8

20 files changed

+969
-56
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nodejs作为服务端的drpy实现。全面升级异步写法
99
* [V我50支付凭证生成器](/authcoder?len=10&number=1)
1010
* [接口压测教程](/docs/httpTest.md)
1111
* [央视点播解析工具](/proxy/央视大全[官]/index.html)
12+
* [cookie管理插件](/apps/cookie-butler/index.html)
1213

1314
## 更新记录
1415

apps/cookie-butler/index.html

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!DOCTYPE html>
2+
<html lang="zh">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Cookie管理</title>
7+
<link rel="stylesheet" href="./static/css/style.css" />
8+
<link rel="stylesheet" href="./static/css/daisyui.min.css" />
9+
<script src="./static/js/tailwindcss.min.js"></script>
10+
<script src="./static/js/axios.min.js"></script>
11+
<script src="./static/js/qrcode.min.js"></script>
12+
<script src="./static/js/core.js"></script>
13+
<script src="./static/js/cookie.js"></script>
14+
</head>
15+
<body class="bg-gray-100 font-sans">
16+
<div class="artboard phone-2 box p-4">
17+
<!-- Navigation Menu -->
18+
<ul class="menu menu-horizontal lg:menu-horizontal bg-base-200 rounded-box mb-4">
19+
<li><a class="btn-scan" data-platform="ali">阿里</a></li>
20+
<li><a class="btn-scan" data-platform="quark">夸克</a></li>
21+
<li><a class="btn-scan" data-platform="uc">UC</a></li>
22+
<li><a class="btn-scan" data-platform="bili">哔哩哔哩</a></li>
23+
</ul>
24+
25+
<!-- QR Code -->
26+
<div class="qrcode-container text-center mb-4">
27+
<img id="qrcode" src="./static/img/qrcode_expired.jpg" alt="二维码" class="mx-auto" />
28+
</div>
29+
30+
<!-- Divider -->
31+
<div class="divider divider-neutral mb-4">请使用手机APP扫码登录</div>
32+
33+
<!-- Textarea with improved styling -->
34+
<textarea
35+
id="cookie-res"
36+
class="textarea textarea-bordered w-full h-40 p-4 bg-white border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
37+
placeholder="扫码确认后将在此处展示cookie"
38+
readonly
39+
></textarea>
40+
41+
<!-- Buttons with improved design -->
42+
<div class="flex justify-center gap-4 mt-4">
43+
<button
44+
id="copy-btn"
45+
class="btn btn-primary w-28 py-2 rounded-lg text-white shadow-lg transform transition-all duration-200 hover:bg-blue-600 hover:scale-105"
46+
onclick="copyToClipboard()"
47+
>
48+
复制
49+
</button>
50+
<button
51+
id="store-btn"
52+
class="btn btn-success w-28 py-2 rounded-lg text-white shadow-lg transform transition-all duration-200 hover:bg-green-600 hover:scale-105"
53+
onclick="storeCookie()"
54+
>
55+
入库
56+
</button>
57+
</div>
58+
</div>
59+
60+
<!-- Toast notification -->
61+
<div class="toast toast-top toast-end">
62+
<div class="toast-content" id="toast" style="display: none;">
63+
<span id="toast-content"></span>
64+
</div>
65+
</div>
66+
67+
<script>
68+
// Copy text to clipboard
69+
function copyToClipboard() {
70+
const textArea = document.getElementById("cookie-res");
71+
textArea.select();
72+
document.execCommand("copy");
73+
74+
// Show success message
75+
const toast = document.getElementById("toast");
76+
const toastContent = document.getElementById("toast-content");
77+
toastContent.textContent = "内容已复制到剪切板";
78+
toast.style.display = "block";
79+
80+
// Hide toast after 2 seconds
81+
setTimeout(() => {
82+
toast.style.display = "none";
83+
}, 2000);
84+
}
85+
86+
// Store cookie (just an alert for now)
87+
function storeCookie() {
88+
alert("入库功能暂未实现!");
89+
}
90+
91+
// Initialize the page
92+
initializePage();
93+
</script>
94+
</body>
95+
</html>

apps/cookie-butler/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "cookie-butler",
3+
"pluginName": "ck管家",
4+
"version": "0.0.1",
5+
"description": "获取Cookie,就是这么简单!用您的手机扫码,立刻解锁专属福利。快来体验‘扫码即得’的便捷吧!",
6+
"main": "index.html",
7+
"logo": "",
8+
"pluginType": "ui",
9+
"author": "Hiram",
10+
"dependencies": {}
11+
}

apps/cookie-butler/static/css/daisyui.min.css

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.box {
2+
background-color: white;
3+
padding: 10px;
4+
border-radius: 10px;
5+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
6+
display: flex;
7+
flex-direction: column;
8+
align-items: center;
9+
justify-content: flex-start;
10+
position: absolute;
11+
top: 50%;
12+
left: 50%;
13+
transform: translate(-50%, -50%);
14+
height: auto !important;
15+
}
16+
17+
.qrcode-container {
18+
position: relative;
19+
margin-top: 10px;
20+
}
21+
22+
#qrcode {
23+
margin-top: 0;
24+
border: 0;
25+
width: 144px;
26+
height: 144px;
27+
cursor: pointer;
28+
}
29+
30+
#cookie-res {
31+
max-height: 200px;
32+
}
33+
34+
.divider {
35+
margin: 10px 0 !important;
36+
}
9.33 KB
Loading

apps/cookie-butler/static/js/axios.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
const qrcode_handler = new QRCodeHandler();
2+
3+
// 显示提示框
4+
function showToast(message, type = 'success') {
5+
const toastEle = document.getElementById('toast');
6+
const toastContentEle = document.getElementById('toast-content');
7+
8+
if (toastEle && toastContentEle) {
9+
toastContentEle.textContent = message;
10+
toast.className = `alert alert-${type}`;
11+
toast.style = 'display: block;'
12+
13+
setTimeout(() => {
14+
toast.style = 'display: none;';
15+
toastContentEle.textContent = '';
16+
}, 3000);
17+
}
18+
}
19+
20+
// 初始化页面
21+
async function initializePage() {
22+
// 加载cookie
23+
const platforms = ['ali', 'quark', 'uc', 'bili'];
24+
25+
// 绑定按钮事件
26+
platforms.forEach(platform => {
27+
// 扫码按钮
28+
const scanBtn = document.querySelector(`.btn-scan[data-platform="${platform}"]`);
29+
if (scanBtn) {
30+
scanBtn.addEventListener('click', () => {
31+
// 清除已有内容
32+
const inputEle = document.getElementById('cookie-res');
33+
inputEle.value = '';
34+
// 清除所有元素的active状态
35+
document.querySelectorAll('.btn-scan').forEach(el => el.classList.remove('active'));
36+
// 为当前点击的元素设置active状态
37+
scanBtn.classList.add('active');
38+
// 执行扫码操作
39+
scanCode(platform);
40+
});
41+
}
42+
});
43+
44+
const qrcodeEle = document.getElementById('qrcode');
45+
qrcodeEle.addEventListener('click', () => {
46+
const inputEle = document.getElementById('cookie-res');
47+
inputEle.value = '';
48+
const activeElement = document.querySelector('.btn-scan.active');
49+
if (activeElement) {
50+
scanCode(activeElement.dataset.platform);
51+
}
52+
});
53+
}
54+
55+
// 扫码
56+
let pollInterval;
57+
let timeoutTimer;
58+
async function scanCode(platform) {
59+
if (pollInterval) clearInterval(pollInterval);
60+
if (timeoutTimer) clearTimeout(timeoutTimer);
61+
62+
const qrcode_expired = './static/img/qrcode_expired.jpg';
63+
64+
try {
65+
// 获取二维码
66+
const qrData = await qrcode_handler.startScan(platform);
67+
68+
// 显示二维码
69+
const img = document.getElementById('qrcode');
70+
img.src = qrData.qrcode;
71+
72+
// 开始轮询扫码结果
73+
pollInterval = setInterval(async () => {
74+
try {
75+
const statusData = await qrcode_handler.checkStatus(platform);
76+
switch(statusData.status) {
77+
case 'CONFIRMED':
78+
clearInterval(pollInterval);
79+
clearTimeout(timeoutTimer);
80+
img.src = qrcode_expired;
81+
const input = document.getElementById('cookie-res');
82+
input.value = statusData.token || statusData.cookie;
83+
showToast('扫码成功!');
84+
break;
85+
86+
case 'CANCELED':
87+
clearInterval(pollInterval);
88+
clearTimeout(timeoutTimer);
89+
img.src = qrcode_expired;
90+
showToast('已取消登录', 'error');
91+
break;
92+
93+
case 'EXPIRED':
94+
clearInterval(pollInterval);
95+
clearTimeout(timeoutTimer);
96+
img.src = qrcode_expired;
97+
showToast('二维码已过期,请重试', 'error');
98+
break;
99+
100+
case 'SCANED':
101+
showToast('已扫码,请在手机上确认');
102+
break;
103+
}
104+
} catch (error) {
105+
console.error('Check status error:', error);
106+
img.src = qrcode_expired;
107+
showToast('检查状态失败', 'error');
108+
}
109+
}, 2000);
110+
111+
// 30秒后超时
112+
timeoutTimer = setTimeout(() => {
113+
clearInterval(pollInterval);
114+
img.src = qrcode_expired;
115+
showToast('二维码已过期', 'error');
116+
}, 30000);
117+
118+
} catch (error) {
119+
if (pollInterval) clearInterval(pollInterval);
120+
if (timeoutTimer) clearTimeout(timeoutTimer);
121+
img.src = qrcode_expired;
122+
showToast(`获取二维码失败:${error.message}`, 'error');
123+
}
124+
}
125+

0 commit comments

Comments
 (0)