| 1 | import { chromium } from "playwright-core"; |
| 2 | import { readFileSync, readdirSync, renameSync, mkdirSync } from "fs"; |
| 3 | |
| 4 | const EXE = "/root/.npm/_npx/361ceb562f3b3235/node_modules/playwright-core/.local-browsers/chromium-1228/chrome-linux64/chrome"; |
| 5 | const SCR = "/tmp/claude-0/-shared-projects/26d7af11-61c4-4183-85c3-70d9aac72ef6/scratchpad"; |
| 6 | const REC = "/shared/projects/SteppingApp/promo/rec"; |
| 7 | const BASE = "http://REDACTED-IP:3000"; |
| 8 | const DJ = readFileSync(`${SCR}/.djid`, "utf8").trim(); |
| 9 | const EV = readFileSync(`${SCR}/.evid`, "utf8").trim(); |
| 10 | |
| 11 | const tours = { |
| 12 | s3: { url: "/city/atlanta", dur: 12.15, pts: [[600,275],[455,745],[1245,755],[455,845],[1245,852],[1165,527],[345,272],[700,668]] }, |
| 13 | s4: { url: `/city/atlanta/event/${EV}`, dur: 8.18, pts: [[600,200],[600,463],[690,533],[820,625],[895,864],[660,403]] }, |
| 14 | s6: { url: `/city/atlanta/profile/dj/${DJ}`, dur: 5.55, pts: [[210,130],[520,300],[820,430],[430,500],[300,200]] }, |
| 15 | }; |
| 16 | |
| 17 | const args = ["--no-sandbox","--disable-dev-shm-usage","--use-gl=angle","--use-angle=swiftshader","--enable-unsafe-swiftshader","--ignore-gpu-blocklist"]; |
| 18 | const browser = await chromium.launch({ executablePath: EXE, args }); |
| 19 | |
| 20 | for (const [id, t] of Object.entries(tours)) { |
| 21 | const dir = `${REC}/${id}`; |
| 22 | mkdirSync(dir, { recursive: true }); |
| 23 | const ctx = await browser.newContext({ |
| 24 | viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1, |
| 25 | recordVideo: { dir, size: { width: 1920, height: 1080 } }, |
| 26 | }); |
| 27 | const page = await ctx.newPage(); |
| 28 | await page.goto(`${BASE}${t.url}`, { waitUntil: "networkidle" }); |
| 29 | await page.mouse.move(960, 540); |
| 30 | await page.waitForTimeout(900); |
| 31 | const end = Date.now() + t.dur * 1000; |
| 32 | let i = 0; |
| 33 | while (Date.now() < end) { |
| 34 | const [x, y] = t.pts[i % t.pts.length]; |
| 35 | await page.mouse.move(x, y, { steps: 28 }); |
| 36 | if (i % 3 === 2) await page.mouse.click(x, y); |
| 37 | await page.waitForTimeout(420); |
| 38 | i++; |
| 39 | } |
| 40 | await ctx.close(); |
| 41 | const f = readdirSync(dir).find((x) => x.endsWith(".webm")); |
| 42 | renameSync(`${dir}/${f}`, `${REC}/${id}.webm`); |
| 43 | console.log(id, "re-recorded (cursor tour)"); |
| 44 | } |
| 45 | await browser.close(); |
| 46 | console.log("DONE"); |