A2C工单修复

This commit is contained in:
root
2026-07-03 20:12:20 +08:00
parent c3223f026e
commit 0f3eb53afe
21 changed files with 1561 additions and 172 deletions
+35 -3
View File
@@ -20,6 +20,34 @@ function urlIndicatesCfChallenge(url) {
|| url.includes('/cdn-cgi/challenge');
}
/** CF 挑战态查询参数(CapSolver websiteURL 需剔除) */
const CF_CHALLENGE_QUERY_KEYS = [
'__cf_chl_rt_tk',
'__cf_chl_tk',
'__cf_chl_f_tk',
'__cf_chl_captcha_tk__',
];
/**
* 去掉 URL 中 CF 挑战临时参数,供 CapSolver / reload 使用
* @param {string} url
* @returns {string}
*/
function sanitizePageUrlForCfSolver(url) {
if (!url || typeof url !== 'string') {
return url || '';
}
try {
const parsed = new URL(url);
for (const key of CF_CHALLENGE_QUERY_KEYS) {
parsed.searchParams.delete(key);
}
return parsed.toString();
} catch (_) {
return url.split('?')[0] || url;
}
}
/**
* 是否要求 cf_clearance 才视为过盾完成(A2C user.a2c.chat 为 false
* @param {object|null|undefined} antiBot
@@ -61,7 +89,9 @@ async function detectCloudflare(page, antiBot = null) {
hasTurnstileWidget,
hasChallengeRunning,
titleHasJustAMoment: titleText.includes('Just a moment'),
bodyHasJustAMoment: bodyText.includes('Just a moment') || bodyText.includes('Checking your browser'),
bodyHasJustAMoment: bodyText.includes('Just a moment')
|| bodyText.includes('Checking your browser')
|| bodyText.includes('Performing security verification'),
};
}).catch(() => ({
hasTurnstileInput: false,
@@ -77,7 +107,8 @@ async function detectCloudflare(page, antiBot = null) {
|| domSignals.titleHasJustAMoment
|| domSignals.bodyHasJustAMoment
|| domSignals.hasChallengeRunning
|| title.includes('Just a moment');
|| title.includes('Just a moment')
|| title.includes('Performing security verification');
const turnstileSignals = domSignals.hasTurnstileInput || domSignals.hasTurnstileWidget;
@@ -93,7 +124,7 @@ async function detectCloudflare(page, antiBot = null) {
if (requireClearance) {
blocked = !hasCfClearance && (realChallenge || turnstileSignals);
} else {
blocked = realChallenge;
blocked = realChallenge || (turnstileSignals && urlChallenge);
}
return {
@@ -129,4 +160,5 @@ module.exports = {
isTurnstileSolved,
urlIndicatesCfChallenge,
isCfClearanceRequired,
sanitizePageUrlForCfSolver,
};