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

Update from GitHub Actions

Browse files
Files changed (1) hide show
  1. src/index.ts +23 -1
src/index.ts CHANGED
@@ -222,7 +222,29 @@ app.get('/genspark', async (c) => {
222
  return c.json({ code: 500, message: '获取令牌失败' })
223
  });
224
 
225
- return c.json({ code: 200, message: '获取令牌成功', token: token })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  }
227
  catch (error) {
228
  console.error('获取令牌失败:', error)
 
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)