File size: 1,013 Bytes
4a84245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c343361
4a84245
 
 
c343361
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import schedule from "node-schedule";
import { chromium } from "playwright";

const SUBDOMAIN = process.env.FALIX_SUBDOMAIN;
const START_URL  = "https://falixnodes.net/startserver";

async function keepAlive() {
  const browser = await chromium.launch({ headless: true });
  const page    = await browser.newPage();
  await page.goto(START_URL, { waitUntil: "networkidle" });

  await page.fill('input[type="text"]', SUBDOMAIN);

  const siteKey = await page.getAttribute("div.cf-turnstile", "data-sitekey");
  const token = await page.evaluate((key) => {
    return new Promise((resolve) => {
      window.turnstile.render(document.querySelector("div.cf-turnstile"), {
        sitekey: key,
        callback: resolve
      });
    });
  }, siteKey);

  await page.fill('input[name="cf-turnstile-response"]', token);
  await page.click('button[type="submit"]');

  await browser.close();
  console.log(new Date(), "✅ Server start request sent.");
}

schedule.scheduleJob("*/55 * * * *", keepAlive);
keepAlive();