github-actions[bot] commited on
Commit
23645dc
·
1 Parent(s): cd9af8b

Update from GitHub Actions

Browse files
Files changed (1) hide show
  1. src/index.ts +5 -20
src/index.ts CHANGED
@@ -49,28 +49,12 @@ async function initGensparkPage(cookies?: any[]) {
49
  acceptDownloads: true,
50
  })
51
  }
52
- if (cookies && cookies.length > 0) {
53
- await gensparkContext.addCookies(cookies);
54
- }
55
  if (!gensparkPage) {
56
  gensparkPage = await gensparkContext.newPage()
57
-
58
- // 修改 webdriver navigator 属性以避免自动化检测
59
- await gensparkPage.addInitScript(() => {
60
- // 覆盖 webdriver 属性
61
- Object.defineProperty(navigator, 'webdriver', {
62
- get: () => false,
63
- });
64
-
65
- // 修改 user-agent 中的 HeadlessChrome 字符串
66
- const userAgent = navigator.userAgent;
67
- if (userAgent.includes('HeadlessChrome')) {
68
- Object.defineProperty(navigator, 'userAgent', {
69
- get: () => userAgent.replace('HeadlessChrome', 'Chrome'),
70
- });
71
- }
72
- });
73
-
74
  // 首次加载页面
75
  await gensparkPage.goto('https://www.genspark.ai', {
76
  waitUntil: 'networkidle',
@@ -78,6 +62,7 @@ async function initGensparkPage(cookies?: any[]) {
78
  })
79
  console.log('GenSpark页面已初始化')
80
  }
 
81
  return gensparkPage
82
  }
83
 
 
49
  acceptDownloads: true,
50
  })
51
  }
52
+
 
 
53
  if (!gensparkPage) {
54
  gensparkPage = await gensparkContext.newPage()
55
+ }
56
+ if (cookies && cookies.length > 0) {
57
+ await gensparkContext.addCookies(cookies);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  // 首次加载页面
59
  await gensparkPage.goto('https://www.genspark.ai', {
60
  waitUntil: 'networkidle',
 
62
  })
63
  console.log('GenSpark页面已初始化')
64
  }
65
+
66
  return gensparkPage
67
  }
68