| const { createServer } = require('node:http') | |
| const { env } = require('node:process') | |
| const cb = (_, res) => res.end('goodbye world.') | |
| createServer(cb).listen(env.SERVER_PORT || env.PORT) | |
| const url = env.URL | |
| const headers = new Headers() | |
| headers.append('user-agent', env.UA) | |
| headers.append('x-pjax-container', '#p0') | |
| headers.append('x-pjax', 'true') | |
| headers.append('sec-ch-ua-platform', '"Android"') | |
| headers.append('sec-ch-ua', '"Android WebView";v="141", "Not?A_Brand";v="8", "Chromium";v="141"') | |
| headers.append('sec-ch-ua-mobile', '?1') | |
| headers.append('x-requested-with', 'XMLHttpRequest') | |
| headers.append('origin', new URL(url).origin) | |
| headers.append('sec-fetch-site', 'same-origin') | |
| headers.append('sec-fetch-mode', 'cors') | |
| headers.append('sec-fetch-dest', 'empty') | |
| headers.append('referer', url) | |
| headers.append('priority', 'u=1, i') | |
| headers.append('cookie', env.COOKIE) | |
| const getCsrfToken = async () => { | |
| const html = await (await fetch(url, { headers })).text() | |
| const token = html.match(/-token" content="(.*?)"/) | |
| return token?.[1] | |
| } | |
| setInterval(async () => { | |
| const token = await getCsrfToken() | |
| const body = new FormData() | |
| body.append('_csrf-frontend', token) | |
| body.append('ExtendFreePlanForm[captcha]', '') | |
| const resp = await fetch(url, { method: 'POST', headers, body }) | |
| const html = await resp.text() | |
| console.log(html) | |
| }, 28 * 60 * 1e3) |