diff --git a/scripts/shots-myket.js b/scripts/shots-myket.js new file mode 100644 index 0000000..4fe9a3b --- /dev/null +++ b/scripts/shots-myket.js @@ -0,0 +1,56 @@ +// Capture 9:16 store screenshots (1080x1920) for Myket from the dev server. +// Output -> store-assets/myket/*.png +const { chromium } = require("playwright"); +const fs = require("fs"); +const path = require("path"); + +const OUT = path.join(__dirname, "..", "store-assets", "myket"); +fs.mkdirSync(OUT, { recursive: true }); +const URL = process.env.SHOT_URL || "http://localhost:3025/"; + +const shot = (page, name) => page.screenshot({ path: path.join(OUT, name + ".png") }); +const tap = (page, text) => page.getByText(text, { exact: false }).first().click({ timeout: 6000 }); + +(async () => { + const browser = await chromium.launch({ channel: "chrome" }); + // 432x768 CSS = 9:16, at DSF 2.5 -> 1080x1920 output (exactly 9:16, < 3000px). + const ctx = await browser.newContext({ + viewport: { width: 432, height: 768 }, + deviceScaleFactor: 2.5, + locale: "fa-IR", + isMobile: true, + hasTouch: true, + }); + const page = await ctx.newPage(); + await page.goto(URL, { waitUntil: "networkidle" }).catch(() => {}); + await page.waitForTimeout(3000); + await shot(page, "01-home"); + + for (const [label, name] of [ + ["جدول امتیازات", "02-leaderboard"], + ["فروشگاه", "03-shop"], + ["دستاوردها", "04-achievements"], + ["پروفایل", "05-profile"], + ]) { + try { + await tap(page, label); + await page.waitForTimeout(2200); + await shot(page, name); + } catch (e) { + console.log("skip", name, String(e).split("\n")[0]); + } + await page.goto(URL, { waitUntil: "networkidle" }).catch(() => {}); + await page.waitForTimeout(1500); + } + + try { + await tap(page, "بازی با کامپیوتر"); + await page.waitForTimeout(5000); + await shot(page, "06-game"); + } catch (e) { + console.log("skip game", String(e).split("\n")[0]); + } + + await browser.close(); + console.log("DONE"); +})().catch((e) => { console.error("FATAL", e); process.exit(1); });