Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Sheet8 * File : scripts/_shot.mts9 * Module : scripts10 * Repository : https://git.spboucher.ai/sheet11 * Project Website : https://sheet.spboucher.ai12 * Created : 2026-11-1713 * Last Modified : 2026-11-1714 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// Design aid: screenshots of pages. tsx scripts/_shot.mts <outdir> <width> <url> [<url>…]44import { chromium } from "playwright-core";45const [dir, w, ...urls] = process.argv.slice(2);46const b = await chromium.launch();47const ctx = await b.newContext({ viewport: { width: +w, height: 900 }, deviceScaleFactor: +w < 600 ? 2 : 1, reducedMotion: "reduce" });48for (const u of urls) {49 const p = await ctx.newPage();50 await p.goto(u, { waitUntil: "networkidle" });51 await p.evaluate(() => document.fonts.ready.then(() => undefined));52 await p.waitForTimeout(500);53 const name = (new URL(u).pathname.replace(/\W+/g, "_") || "home") + "_" + w;54 const h = await p.evaluate(() => document.documentElement.scrollHeight);55 const step = 2600; let i = 0;56 for (let y = 0; y < h; y += step, i++) await p.screenshot({ path: `${dir}/${name}_${i}.png`, fullPage: true, clip: { x: 0, y, width: +w, height: Math.min(step, h - y) } });57 const errs = await p.evaluate(() => [...document.querySelectorAll(".katex-error, .sh-math-fallback")].map((e) => e.textContent));58 console.log(name, h, i, "math errors:", JSON.stringify(errs));59 await p.close();60}61await b.close();62