This commit is contained in:
luk
2026-08-09 17:43:39 +08:00
parent e6b31fa5bf
commit bc1099183e
2 changed files with 9 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ Run the script with:
`node renew.mjs 'EMAIL' 'PASSWORD'` `node renew.mjs 'EMAIL' 'PASSWORD'`
you can also set environment variables directly: you can also set environment variables directly:
`HEADLESs=true UNICLOUD_EMAIL=... UNICLOUD_PASSWORD=... node renew.mjs` `HEADLESS=true UNICLOUD_EMAIL=... UNICLOUD_PASSWORD=... node renew.mjs`
or set via `.env` file. or set via `.env` file.

View File

@@ -80,13 +80,15 @@ async function renewOne (context, dashboardPage, renewLocator, index) {
;(async () => { ;(async () => {
const isMac = process.platform === 'darwin' const isMac = process.platform === 'darwin'
// Set HEADLESS=false (or omit) to watch the browser; cron jobs should run // Set HEADLESS=false (or omit) to watch the browser; cron jobs should run
// headless (HEADLESS=true or just leave it — defaults to true when no TTY). // headless (HEADLESS=true or just leave it — defaults to true when no TTY).
const headless = const headless =
process.env.HEADLESS != null process.env.HEADLESS != null
? process.env.HEADLESS !== 'false' && process.env.HEADLESS !== '0' ? process.env.HEADLESS !== 'false' && process.env.HEADLESS !== '0'
: isMac ? false : true : isMac
? false
: true
// On macOS use the installed Microsoft Edge; on Linux (and elsewhere) fall // On macOS use the installed Microsoft Edge; on Linux (and elsewhere) fall
// back to the Chromium bundled by Playwright (run `npx playwright install // back to the Chromium bundled by Playwright (run `npx playwright install
@@ -111,7 +113,7 @@ async function renewOne (context, dashboardPage, renewLocator, index) {
timeout: 60000 timeout: 60000
}) })
console.log('<<<<<<<<<', new Date().toJSON(), 'Renew account', email) console.log('\n<<<<<<<<<\n', new Date().toJSON(), 'Renew account', email)
console.log('Page loaded, waiting for login iframe...') console.log('Page loaded, waiting for login iframe...')
// 1. Login via the account.dcloud.net.cn iframe. // 1. Login via the account.dcloud.net.cn iframe.
@@ -163,10 +165,10 @@ async function renewOne (context, dashboardPage, renewLocator, index) {
} }
console.log( console.log(
'>>>>>>>>>',
new Date().toJSON(), new Date().toJSON(),
`Done. ${done} subscription(s) renewed for accouint`, `Done. ${done} subscription(s) renewed for account`,
email email,
'\n>>>>>>>>>\n'
) )
await browser.close() await browser.close()
process.exit(0) process.exit(0)