github-actions[bot] commited on
Commit
7eb49d7
·
1 Parent(s): f537e7c

Update from GitHub Actions

Browse files
Files changed (1) hide show
  1. src/index.ts +3 -24
src/index.ts CHANGED
@@ -193,12 +193,13 @@ app.get('/genspark', async (c) => {
193
 
194
  const gensparkPage = await initGensparkPage(cookies)
195
  try {
 
196
  //刷新页面以确保获取新令牌
197
  await gensparkPage.goto('https://www.genspark.ai/agents?type=moa_chat', {
198
  waitUntil: 'networkidle',
199
  timeout: 3600000
200
  })
201
-
202
  // 执行脚本获取令牌
203
  const token = await gensparkPage.evaluate(() => {
204
  return new Promise((resolve, reject) => {
@@ -222,29 +223,7 @@ app.get('/genspark', async (c) => {
222
  return c.json({ code: 500, message: '获取令牌失败' })
223
  });
224
 
225
- const token2 = await gensparkPage.evaluate(() => {
226
- return new Promise((resolve, reject) => {
227
- // @ts-ignore
228
- window.grecaptcha.ready(function () {
229
- // @ts-ignore
230
- grecaptcha.execute(
231
- "6Leq7KYqAAAAAGdd1NaUBJF9dHTPAKP7DcnaRc66",
232
- { action: 'copilot' },
233
- ).then(function (token: string) {
234
- resolve(token)
235
- }).catch(function (error: Error) {
236
- reject(error)
237
- });
238
- });
239
-
240
- // 设置超时
241
- setTimeout(() => reject(new Error("获取令牌超时")), 10000);
242
- });
243
- }).catch(error => {
244
- return c.json({ code: 500, message: '获取令牌失败' })
245
- });
246
-
247
- return c.json({ code: 200, message: '获取令牌成功', token: token2 })
248
  }
249
  catch (error) {
250
  console.error('获取令牌失败:', error)
 
193
 
194
  const gensparkPage = await initGensparkPage(cookies)
195
  try {
196
+ await gensparkPage.waitForTimeout(1000)
197
  //刷新页面以确保获取新令牌
198
  await gensparkPage.goto('https://www.genspark.ai/agents?type=moa_chat', {
199
  waitUntil: 'networkidle',
200
  timeout: 3600000
201
  })
202
+ await gensparkPage.waitForTimeout(1000)
203
  // 执行脚本获取令牌
204
  const token = await gensparkPage.evaluate(() => {
205
  return new Promise((resolve, reject) => {
 
223
  return c.json({ code: 500, message: '获取令牌失败' })
224
  });
225
 
226
+ return c.json({ code: 200, message: '获取令牌成功', token: token })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
  catch (error) {
229
  console.error('获取令牌失败:', error)