Arkm20 commited on
Commit
c343361
·
verified ·
1 Parent(s): 0b803d1

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +2 -9
index.js CHANGED
@@ -9,13 +9,9 @@ async function keepAlive() {
9
  const page = await browser.newPage();
10
  await page.goto(START_URL, { waitUntil: "networkidle" });
11
 
12
- // 1. Fill in the "Server Subdomain Name" field
13
  await page.fill('input[type="text"]', SUBDOMAIN);
14
 
15
- // 2. Wait for the Turnstile widget, grab its sitekey
16
  const siteKey = await page.getAttribute("div.cf-turnstile", "data-sitekey");
17
-
18
- // 3. Execute Turnstile in-page to get a token
19
  const token = await page.evaluate((key) => {
20
  return new Promise((resolve) => {
21
  window.turnstile.render(document.querySelector("div.cf-turnstile"), {
@@ -25,15 +21,12 @@ async function keepAlive() {
25
  });
26
  }, siteKey);
27
 
28
- // 4. Inject the token and click “Start Server”
29
  await page.fill('input[name="cf-turnstile-response"]', token);
30
  await page.click('button[type="submit"]');
31
 
32
  await browser.close();
33
- console.log(new Date(), "✅ Start request sent");
34
  }
35
 
36
- // Schedule every 55 minutes to stay ahead of the ~1 hr free-tier shutdown :contentReference[oaicite:0]{index=0}
37
  schedule.scheduleJob("*/55 * * * *", keepAlive);
38
- // Run immediately on container start
39
- keepAlive();
 
9
  const page = await browser.newPage();
10
  await page.goto(START_URL, { waitUntil: "networkidle" });
11
 
 
12
  await page.fill('input[type="text"]', SUBDOMAIN);
13
 
 
14
  const siteKey = await page.getAttribute("div.cf-turnstile", "data-sitekey");
 
 
15
  const token = await page.evaluate((key) => {
16
  return new Promise((resolve) => {
17
  window.turnstile.render(document.querySelector("div.cf-turnstile"), {
 
21
  });
22
  }, siteKey);
23
 
 
24
  await page.fill('input[name="cf-turnstile-response"]', token);
25
  await page.click('button[type="submit"]');
26
 
27
  await browser.close();
28
+ console.log(new Date(), "✅ Server start request sent.");
29
  }
30
 
 
31
  schedule.scheduleJob("*/55 * * * *", keepAlive);
32
+ keepAlive();