bobocup commited on
Commit
402f38e
·
verified ·
1 Parent(s): e341326

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +10 -3
index.js CHANGED
@@ -107,15 +107,18 @@ class TokenManager {
107
  if (isWaf) {
108
  var wafToken = await Utils.extractWaf();
109
  if (wafToken) {
 
110
  Tokens[currentIndex].aws_waf_token = wafToken;
 
111
  await this.updateCacheTokens();
112
- this.updateRedisTokens();
 
 
113
  currentIndex = (currentIndex + 1) % Tokens.length;
114
- console.log("成功提取 aws-waf-token");
115
  } else {
 
116
  currentIndex = (currentIndex + 1) % Tokens.length;
117
  await this.updateCacheTokens();
118
- console.log("提取aws-waf-token失败");
119
  }
120
  } else {
121
  const newCsrfToken = response.headers.get('anti-csrftoken-a2z');
@@ -235,6 +238,10 @@ class Utils {
235
  timeout: 30000
236
  });
237
 
 
 
 
 
238
  // 获取最终token
239
  const awsWafToken = (await page.cookies()).find(
240
  cookie => cookie.name.toLowerCase() === 'aws-waf-token'
 
107
  if (isWaf) {
108
  var wafToken = await Utils.extractWaf();
109
  if (wafToken) {
110
+ // 更新当前token的aws_waf_token
111
  Tokens[currentIndex].aws_waf_token = wafToken;
112
+ // 立即更新缓存headers
113
  await this.updateCacheTokens();
114
+ // 更新Redis存储
115
+ await this.updateRedisTokens();
116
+ console.log("✅ 成功更新aws-waf-token到缓存");
117
  currentIndex = (currentIndex + 1) % Tokens.length;
 
118
  } else {
119
+ console.log("❌ 提取aws-waf-token失败,切换账号");
120
  currentIndex = (currentIndex + 1) % Tokens.length;
121
  await this.updateCacheTokens();
 
122
  }
123
  } else {
124
  const newCsrfToken = response.headers.get('anti-csrftoken-a2z');
 
238
  timeout: 30000
239
  });
240
 
241
+ // 新增:等待验证完成
242
+ await page.waitForTimeout(1000); // 等待1秒确保验证完成
243
+ await page.waitForSelector('.aws-waf-challenge', { hidden: true, timeout: 15000 });
244
+
245
  // 获取最终token
246
  const awsWafToken = (await page.cookies()).find(
247
  cookie => cookie.name.toLowerCase() === 'aws-waf-token'