// Captures d'écran du site en prod pour le README (jetable). import { chromium } from "playwright"; import { mkdirSync } from "fs"; const OUT = "docs/screenshots"; mkdirSync(OUT, { recursive: true }); const BASE = "https://www.vrai-prix.com"; const FICHE = "/estimation/66023993631880550000000"; const SHOTS = [ { path: "/", name: "accueil", wait: 2500 }, { path: FICHE, name: "fiche-estimation", wait: 3500 }, { path: FICHE, name: "fiche-portrait", wait: 3500, scrollTo: 1800 }, { path: "/carte", name: "carte", wait: 9000 }, { path: "/stats", name: "stats", wait: 3200 }, { path: "/ka", name: "ka-agent", wait: 2500 }, { path: "/municipalite/gatineau", name: "municipalite", wait: 2000 }, { path: "/methodologie", name: "methodologie", wait: 2000 }, { path: "/", name: "accueil-mobile", wait: 2500, mobile: true }, { path: FICHE, name: "fiche-mobile", wait: 3500, mobile: true }, ]; const browser = await chromium.launch(); for (const s of SHOTS) { const ctx = await browser.newContext({ viewport: s.mobile ? { width: 390, height: 844 } : { width: 1440, height: 900 }, deviceScaleFactor: 2, locale: "fr-CA", isMobile: !!s.mobile, }); // masque le bandeau de témoins (consentement déjà donné) await ctx.addInitScript(() => { try { localStorage.setItem( "vp-cookie-consent", JSON.stringify({ necessary: true, analytics: false, ts: 1755000000000 }) ); localStorage.setItem("vp-lang", "fr"); } catch {} }); const page = await ctx.newPage(); await page.goto(BASE + s.path, { waitUntil: "networkidle", timeout: 60000 }).catch(() => {}); await page.waitForTimeout(s.wait); if (s.scrollTo) { await page.evaluate((y) => window.scrollTo({ top: y, behavior: "instant" }), s.scrollTo); await page.waitForTimeout(1200); } await page.screenshot({ path: `${OUT}/${s.name}.png` }); console.log("✓", s.name); await ctx.close(); } await browser.close();