Skip to content

Commit c105d0f

Browse files
author
Taois
committed
feat: 合并秋秋提供的扫码入库界面代码
1 parent b1b4452 commit c105d0f

File tree

3 files changed

+55
-11
lines changed

3 files changed

+55
-11
lines changed

apps/cookie-butler/index.html

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@
1212
<script src="./static/js/crypto-js.min.js"></script>
1313
<script src="./static/js/core.js"></script>
1414
<script src="./static/js/cookie.js"></script>
15+
<script src="./static/js/jsencrypt.min.js"></script>
1516
</head>
1617
<body class="bg-gray-100 font-sans">
1718
<div class="artboard phone-2 box p-4">
1819
<!-- Navigation Menu -->
1920
<ul class="menu menu-horizontal lg:menu-horizontal bg-base-200 rounded-box mb-4">
2021
<li><a class="btn-scan" data-platform="ali">阿里</a></li>
2122
<li><a class="btn-scan" data-platform="quark">夸克</a></li>
23+
<li><a class="btn-scan" data-platform="quark_token">夸克TV</a></li>
2224
<li><a class="btn-scan" data-platform="uc">UC</a></li>
2325
<li><a class="btn-scan" data-platform="uc_token">UC_TOKEN</a></li>
2426
<li><a class="btn-scan" data-platform="bili">哔哩哔哩</a></li>
27+
<li><a class="btn-scan" data-platform="yun">移动</a></li>
2528
<li><a class="btn-scan" data-platform="baidu">百度</a></li>
29+
<li><a class="btn-scan" data-platform="pikpak">PikPak</a></li>
2630
</ul>
2731

2832
<!-- QR Code -->
@@ -93,28 +97,67 @@
9397
const textValue = document.getElementById("cookie-res").value || '';
9498
const active_name = activeLi.textContent.trim();
9599
const active_key = activeLi.getAttribute('data-platform').trim();
96-
const save_key = active_key === 'ali' ? active_key + '_token' : active_key + '_cookie';
100+
let save_key = ''
101+
if (/ali|pikpak/.test(active_key)) {
102+
save_key = active_key + '_token'
103+
} else {
104+
save_key = active_key + '_cookie';
105+
}
106+
97107
console.log(`准备入库cookie:${active_name} ${save_key},值为:${textValue}`);
98108

99109
const cookie_auth_code = prompt('cookie入库功能需要管理员授权码,请你正确输入后继续');
100110
if (cookie_auth_code) {
101-
// 使用 axios 发送 POST 请求
102-
axios.post('/admin/cookie-set', {
103-
cookie_auth_code: cookie_auth_code,
104-
key: save_key,
105-
value: textValue.trim().replaceAll('\n', '')
106-
})
107-
.then(response => {
111+
if (save_key.includes('pikpak')) {
112+
// 使用 axios 发送 POST 请求
113+
axios.post('/admin/cookie-set', {
114+
cookie_auth_code: cookie_auth_code,
115+
key: save_key,
116+
value: textValue.split(';')[0].trim().replaceAll('\n', '')
117+
}).then(response => {
108118
if (response.data.success) {
109119
alert(`Cookie 入库成功:${active_name} (${save_key})`);
110120
} else {
111121
alert(`入库失败:${response.data.message}`);
112122
}
113-
})
114-
.catch(error => {
123+
}).catch(error => {
124+
console.error('请求失败:', error);
125+
alert(`入库失败,服务器出现问题,请稍后再试。\n${error.response.data.message}`);
126+
});
127+
axios.post('/admin/cookie-set', {
128+
cookie_auth_code: cookie_auth_code,
129+
key: save_key.replace('token', 'refresh_token'),
130+
value: textValue.split(';')[1].trim().replaceAll('\n', '')
131+
}).then(response => {
132+
if (response.data.success) {
133+
alert(`Cookie 入库成功:${active_name} (${save_key.replace('token', 'refresh_token')})`);
134+
} else {
135+
alert(`入库失败:${response.data.message}`);
136+
}
137+
}).catch(error => {
115138
console.error('请求失败:', error);
116139
alert(`入库失败,服务器出现问题,请稍后再试。\n${error.response.data.message}`);
117140
});
141+
} else {
142+
// 使用 axios 发送 POST 请求
143+
axios.post('/admin/cookie-set', {
144+
cookie_auth_code: cookie_auth_code,
145+
key: save_key,
146+
value: textValue.trim().replaceAll('\n', '')
147+
})
148+
.then(response => {
149+
if (response.data.success) {
150+
alert(`Cookie 入库成功:${active_name} (${save_key})`);
151+
} else {
152+
alert(`入库失败:${response.data.message}`);
153+
}
154+
})
155+
.catch(error => {
156+
console.error('请求失败:', error);
157+
alert(`入库失败,服务器出现问题,请稍后再试。\n${error.response.data.message}`);
158+
});
159+
}
160+
118161
}
119162
} else {
120163
alert('至少选中一个cookie入库项目');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function showToast(message, type = 'success') {
2020
// 初始化页面
2121
async function initializePage() {
2222
// 加载cookie
23-
const platforms = ['ali', 'quark', 'uc', 'uc_token', 'bili', 'baidu'];
23+
const platforms = ['ali', 'quark', 'quark_token', 'uc', 'uc_token', 'bili', 'yun', 'baidu', 'pikpak'];
2424

2525
// 绑定按钮事件
2626
platforms.forEach(platform => {

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

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)