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" }); // 1. Fill in the "Server Subdomain Name" field await page.fill('input[type="text"]', SUBDOMAIN); // 2. Wait for the Turnstile widget, grab its sitekey const siteKey = await page.getAttribute("div.cf-turnstile", "data-sitekey"); // 3. Execute Turnstile in-page to get a token const token = await page.evaluate((key) => { return new Promise((resolve) => { window.turnstile.render(document.querySelector("div.cf-turnstile"), { sitekey: key, callback: resolve }); }); }, siteKey); // 4. Inject the token and click “Start Server” await page.fill('input[name="cf-turnstile-response"]', token); await page.click('button[type="submit"]'); await browser.close(); console.log(new Date(), "✅ Start request sent"); } // Schedule every 55 minutes to stay ahead of the ~1 hr free-tier shutdown :contentReference[oaicite:0]{index=0} schedule.scheduleJob("*/55 * * * *", keepAlive); // Run immediately on container start keepAlive();