fix: rotate once per errored phone number
This commit is contained in:
+10
-15
@@ -33,10 +33,8 @@
|
||||
let autoRotateTimer = null;
|
||||
let autoRotateInFlight = false;
|
||||
let autoRotateEnabled = true;
|
||||
let lastAutoRotateSignature = '';
|
||||
let lastAutoRotateAt = 0;
|
||||
let lastErroredPhoneNumber = '';
|
||||
const AUTO_ROTATE_DEBOUNCE_MS = 800;
|
||||
const AUTO_ROTATE_COOLDOWN_MS = 8000;
|
||||
|
||||
function stopCodePolling() {
|
||||
codePollToken += 1;
|
||||
@@ -170,6 +168,7 @@
|
||||
await copyText(phone);
|
||||
fillPhone(phone);
|
||||
$('.sb-current-phone').textContent = phone;
|
||||
lastErroredPhoneNumber = '';
|
||||
$('.sb-current-id').textContent = res.activation.activationId;
|
||||
const codeNode = $('.sb-current-code');
|
||||
if (codeNode) codeNode.textContent = '无';
|
||||
@@ -195,25 +194,21 @@
|
||||
btn.classList.toggle('sb-auto-on', autoRotateEnabled);
|
||||
}
|
||||
|
||||
function buildAutoRotateSignature(reason, text) {
|
||||
const compact = String(text || '').replace(/\s+/g, ' ').trim();
|
||||
return `${reason}:${compact.slice(-220)}`;
|
||||
function getCurrentPhoneNumber() {
|
||||
const phone = $('.sb-current-phone')?.textContent || latestSettings?.activeActivation?.phoneNumber || '';
|
||||
return String(phone).trim();
|
||||
}
|
||||
|
||||
async function rotateFromClassifiedError(classified, source = 'manual') {
|
||||
const text = getPageTextForPhoneError();
|
||||
const signature = buildAutoRotateSignature(classified.reason, text);
|
||||
const now = Date.now();
|
||||
const currentPhone = getCurrentPhoneNumber();
|
||||
if (autoRotateInFlight) return false;
|
||||
if (source === 'auto' && signature === lastAutoRotateSignature && now - lastAutoRotateAt < AUTO_ROTATE_COOLDOWN_MS) {
|
||||
return false;
|
||||
}
|
||||
if (source === 'auto' && (!currentPhone || currentPhone === '无')) return false;
|
||||
if (source === 'auto' && currentPhone === lastErroredPhoneNumber) return false;
|
||||
autoRotateInFlight = true;
|
||||
lastAutoRotateSignature = signature;
|
||||
lastAutoRotateAt = now;
|
||||
try {
|
||||
lastErroredPhoneNumber = currentPhone;
|
||||
setStatus(source === 'auto'
|
||||
? `检测到${classified.reason === 'phone_number_used' ? '号码已使用' : '验证码发送失败'},正在自动切号...`
|
||||
? `当前号码 ${currentPhone} 触发${classified.reason === 'phone_number_used' ? '已使用' : '验证码发送失败'},正在自动切下一个号...`
|
||||
: '检测到手机号错误,正在切号...');
|
||||
await fetchAndFill({ reason: classified.reason, releaseAction: classified.releaseAction, skipSave: true });
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user