creditdaddy 0.8.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +234 -224
- package/bin/creditdaddy.js +9 -9
- package/package.json +1 -1
- package/src/checkin.js +31 -2
- package/src/daemon.js +16 -6
- package/src/panel.html +2065 -1785
- package/src/providers.js +3 -2
- package/src/store.js +28 -3
- package/src/workbuddyClient.js +45 -0
- package/src/zcodeAutoClaim.js +96 -0
- package/src/zcodeClient.js +32 -12
package/src/checkin.js
CHANGED
|
@@ -14,6 +14,8 @@ import { productImpl } from './providers.js';
|
|
|
14
14
|
import { productOf } from './constants.js';
|
|
15
15
|
import { startUsageSyncScheduler } from './tenrouter.js';
|
|
16
16
|
import { refreshContext } from './accounts.js';
|
|
17
|
+
import { zcodeAutoClaim } from './zcodeAutoClaim.js';
|
|
18
|
+
import { autoClaimEnabled } from './zcodeClient.js';
|
|
17
19
|
import { logger } from './logger.js';
|
|
18
20
|
|
|
19
21
|
const TICK_MS = 2 * 60 * 60 * 1000; // 2 小时
|
|
@@ -70,15 +72,24 @@ async function runTickNow(opts) {
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
async function runTickInner(opts) {
|
|
75
|
+
const allAccounts = await loadAccounts();
|
|
73
76
|
// 没有每日签到能力的产品(如 ZCode:积分靠需验证码的活动领取)不参与签到轮
|
|
74
|
-
const accounts =
|
|
77
|
+
const accounts = allAccounts.filter(
|
|
75
78
|
(a) => (!opts.provider || a.provider === opts.provider)
|
|
76
79
|
&& (!opts.product || productOf(a.provider) === opts.product)
|
|
77
80
|
&& (!opts.onlyAccountId || a.id === opts.onlyAccountId)
|
|
78
81
|
&& typeof productImpl(a.provider)?.checkin === 'function'
|
|
79
82
|
);
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
// ZCode 活动轮询领取:开关打开(标签页可切换,默认关)且未被筛选参数排除时参与
|
|
85
|
+
const zAccounts = (autoClaimEnabled()
|
|
86
|
+
&& !opts.onlyAccountId
|
|
87
|
+
&& (!opts.provider || opts.provider === 'zcode')
|
|
88
|
+
&& (!opts.product || opts.product === 'zcode'))
|
|
89
|
+
? allAccounts.filter((a) => a.provider === 'zcode')
|
|
90
|
+
: [];
|
|
91
|
+
|
|
92
|
+
if (accounts.length === 0 && zAccounts.length === 0) {
|
|
82
93
|
return { results: [], summary: '没有匹配的账号' };
|
|
83
94
|
}
|
|
84
95
|
|
|
@@ -152,6 +163,24 @@ async function runTickInner(opts) {
|
|
|
152
163
|
});
|
|
153
164
|
await saveState({ ...state, qoderDailyDone: memo, deviceClaim });
|
|
154
165
|
|
|
166
|
+
// ZCode 活动自动领取:每轮签到后顺带轮询(preview 为空时零请求副作用;需开关打开)。
|
|
167
|
+
// 桌面版已注册隐藏窗口验证码提供者,可静默过验证码;其它环境需要验证码时标记「需手动领取」。
|
|
168
|
+
for (const za of zAccounts) {
|
|
169
|
+
const label = za.name || za.uid || za.id;
|
|
170
|
+
try {
|
|
171
|
+
const r = await zcodeAutoClaim(za);
|
|
172
|
+
if (!r) continue;
|
|
173
|
+
results.push({ accountId: za.id, account: label, provider: 'zcode', status: r.status, message: r.message });
|
|
174
|
+
const lastResult = { status: r.status, message: r.message, amount: 0, at: new Date().toISOString() };
|
|
175
|
+
await withAccounts((list) => {
|
|
176
|
+
const cur = list.find((a) => a.id === za.id);
|
|
177
|
+
if (cur) cur.lastResult = lastResult;
|
|
178
|
+
});
|
|
179
|
+
} catch (e) {
|
|
180
|
+
logger.warn('ZCODE-CLAIM', `${label} 自动领取异常:${e.message}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
155
184
|
const claimed = results.filter((r) => r.status === 'checked-in');
|
|
156
185
|
const failed = results.filter((r) => r.status === 'failed');
|
|
157
186
|
const none = results.filter((r) => r.status === 'no-activity');
|
package/src/daemon.js
CHANGED
|
@@ -50,7 +50,7 @@ import { addAccount, importAccounts, refreshContext } from './accounts.js';
|
|
|
50
50
|
import { productImpl } from './providers.js';
|
|
51
51
|
import { readWorkbuddySessions, writeWorkbuddySession, workbuddyAuthDir, currentWorkbuddyUid } from './workbuddyLocal.js';
|
|
52
52
|
import { liveToAccount as zcodeLiveAccount, switchTo as zcodeSwitchTo, currentZcodeUid, currentZcodeIdentity, detectZcode, ensureVirtualDeviceMid, terminateZcode } from './zcodeLocal.js';
|
|
53
|
-
import { fetchClaimPlans, claimPlan, fetchCaptchaConfig, proxyFirst, setProxyFirst } from './zcodeClient.js';
|
|
53
|
+
import { fetchClaimPlans, claimPlan, fetchCaptchaConfig, proxyFirst, setProxyFirst, proxyUrl, setProxyUrl, autoClaimEnabled, setAutoClaimEnabled } from './zcodeClient.js';
|
|
54
54
|
import { exportAccounts, parseImport, TransferError } from './transfer.js';
|
|
55
55
|
import { runCheckinTick, getSchedulerInfo, dayKey } from './checkin.js';
|
|
56
56
|
import { detectQoderApps, readQoderAppAccounts, riskIdentityAvailable, riskIdentitySource } from './qoderApp.js';
|
|
@@ -246,6 +246,10 @@ async function handleApi(req, res, url) {
|
|
|
246
246
|
region: typeof body.region === 'string' ? body.region : '',
|
|
247
247
|
});
|
|
248
248
|
logger.info('DAEMON', `ZCode ${account.name || account.id} 领取成功:${outcome.planName}`);
|
|
249
|
+
await withAccounts((list) => {
|
|
250
|
+
const cur = list.find((a) => a.id === account.id);
|
|
251
|
+
if (cur) cur.lastResult = { status: 'checked-in', message: `已领取:${outcome.planName}`, amount: 0, at: new Date().toISOString() };
|
|
252
|
+
});
|
|
249
253
|
return json(res, 200, outcome);
|
|
250
254
|
} catch (e) {
|
|
251
255
|
logger.warn('DAEMON', `ZCode ${account.name || account.id} 领取失败:${e.message}`);
|
|
@@ -259,15 +263,21 @@ async function handleApi(req, res, url) {
|
|
|
259
263
|
return json(res, 502, { error: e.message });
|
|
260
264
|
}
|
|
261
265
|
}
|
|
262
|
-
// ZCode
|
|
266
|
+
// ZCode 出口偏好:默认「直连优先、代理兜底」,可切「代理优先、直连兜底」;代理地址可面板配置(存 zcode-net.json,0600)
|
|
263
267
|
if (p === '/api/zcode/net' && method === 'GET') {
|
|
264
|
-
|
|
268
|
+
const u = proxyUrl();
|
|
269
|
+
const masked = u ? (() => { try { const x = new URL(u); x.password = x.password ? '*'.repeat(4) : ''; return x.toString(); } catch { return '***'; } })() : null;
|
|
270
|
+
return json(res, 200, { proxyFirst: proxyFirst(), proxyUrlMasked: masked, autoClaim: autoClaimEnabled(), hasEnvProxy: Boolean(process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy) });
|
|
265
271
|
}
|
|
266
272
|
if (p === '/api/zcode/net' && method === 'PUT') {
|
|
267
273
|
const body = await readBody(req).catch(() => ({}));
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
274
|
+
try {
|
|
275
|
+
if (body?.proxyFirst !== undefined) setProxyFirst(body.proxyFirst === true);
|
|
276
|
+
if (body?.proxyUrl !== undefined) setProxyUrl(body.proxyUrl);
|
|
277
|
+
if (body?.autoClaim !== undefined) setAutoClaimEnabled(body.autoClaim === true);
|
|
278
|
+
} catch (e) { return json(res, 400, { error: e.message }); }
|
|
279
|
+
logger.info('DAEMON', `ZCode 出口:${proxyFirst() ? '代理优先' : '直连优先'},自动领取:${autoClaimEnabled() ? '开' : '关'},代理 ${proxyUrl() || '(环境变量/未设置)'}`);
|
|
280
|
+
return json(res, 200, { proxyFirst: proxyFirst(), autoClaim: autoClaimEnabled() });
|
|
271
281
|
}
|
|
272
282
|
|
|
273
283
|
// 切换 WorkBuddy / ZCode 客户端当前登录账号
|