just shots: screenshots of the whole page at the 3, 2 and 1 column widths

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-28 18:08:13 -07:00
1 parent 29e5103648
commit 0759cbaa25
2 files changed
+28

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
// Screenshots of the whole page at each layout width (3, 2 and 1 column), read
// before any page change is merged. Usage: just shots [url] [out-dir]
const path = require('path');
const { execSync } = require('child_process');
const root = execSync('mise where npm:playwright 2>/dev/null || mise where playwright', { encoding: 'utf8' }).trim();
const { chromium } = require(path.join(root, 'node_modules/playwright'));
const [, , url = 'http://127.0.0.1:8226/', out = 'target/shots'] = process.argv;
(async () => {
require('fs').mkdirSync(out, { recursive: true });
const browser = await chromium.launch({
args: ['--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'],
});
for (const [width, height] of [[1400, 2600], [900, 3600], [390, 5600]]) {
// The page scrolls inside its canvas, so a tall window shows all of it.
const page = await browser.newPage({ viewport: { width, height }, colorScheme: 'dark' });
await page.goto(url);
await page.waitForTimeout(5000);
const file = path.join(out, `page-${width}.png`);
await page.screenshot({ path: file });
console.log(file);
await page.close();
}
await browser.close();
})().catch((error) => { console.error(error); process.exit(1); });