| 1 | import { chromium } from "playwright-core"; |
| 2 | import { readFileSync } from "fs"; |
| 3 | |
| 4 | const EXE = "/root/.npm/_npx/361ceb562f3b3235/node_modules/playwright-core/.local-browsers/chromium-1228/chrome-linux64/chrome"; |
| 5 | const OUT = "/shared/projects/SteppingApp/promo/shots"; |
| 6 | const SCR = "/tmp/claude-0/-shared-projects/26d7af11-61c4-4183-85c3-70d9aac72ef6/scratchpad"; |
| 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 browser = await chromium.launch({ |
| 12 | executablePath: EXE, |
| 13 | args: ["--no-sandbox", "--disable-dev-shm-usage", "--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"], |
| 14 | }); |
| 15 | |
| 16 | const d = await browser.newPage({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 2 }); |
| 17 | const view = async (path, name, settle = 1500, scrollTo = null) => { |
| 18 | await d.goto(`${BASE}${path}`, { waitUntil: "networkidle" }); |
| 19 | if (scrollTo) await d.evaluate((sel) => document.querySelector(sel)?.scrollIntoView({ block: "center" }), scrollTo); |
| 20 | await d.waitForTimeout(settle); |
| 21 | await d.screenshot({ path: `${OUT}/${name}.png` }); |
| 22 | }; |
| 23 | await d.mouse.move(1250, 470); |
| 24 | await view("/", "hero", 2600); |
| 25 | await view("/", "cities", 1400, "#route"); |
| 26 | await view(`/city/atlanta/profile/dj/${DJ}`, "profile", 1200); |
| 27 | |
| 28 | const f = await browser.newPage({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1 }); |
| 29 | const full = async (path, name, settle = 1300) => { |
| 30 | await f.goto(`${BASE}${path}`, { waitUntil: "networkidle" }); |
| 31 | await f.waitForTimeout(settle); |
| 32 | await f.screenshot({ path: `${OUT}/${name}.png`, fullPage: true }); |
| 33 | }; |
| 34 | await full("/city/atlanta", "city"); |
| 35 | await full(`/city/atlanta/event/${EV}`, "event"); |
| 36 | await full("/city/atlanta/yard", "yard"); |
| 37 | await full("/city/atlanta/route", "route"); |
| 38 | await full("/about", "about"); |
| 39 | |
| 40 | const m = await browser.newPage({ viewport: { width: 430, height: 932 }, deviceScaleFactor: 3, isMobile: true, hasTouch: true }); |
| 41 | await m.goto(`${BASE}/`, { waitUntil: "networkidle" }); |
| 42 | await m.waitForTimeout(1800); |
| 43 | await m.screenshot({ path: `${OUT}/mobile.png`, fullPage: false }); |
| 44 | |
| 45 | await browser.close(); |
| 46 | console.log("shots done"); |