// node _tools/shot.mjs [w] [h] [scrollY...] -> out-.png per scroll import pw from '/Users/natebutler/code/stylize/node_modules/playwright/index.js'; const { chromium } = pw; const [url, out, w='1440', h='900', ...ys] = process.argv.slice(2); const browser = await chromium.launch({ args: ['--use-angle=swiftshader','--enable-unsafe-swiftshader'] }); const page = await browser.newPage({ viewport: { width:+w, height:+h } }); const errors=[]; page.on('pageerror',e=>errors.push(e.message)); page.on('console',m=>m.type()==='error'&&errors.push(m.text())); await page.goto(url,{waitUntil:'networkidle'}); await page.waitForTimeout(1500); const list = ys.length? ys : ['0']; for (const y of list){ if (y.startsWith('hover:')) { await page.hover(y.slice(6)); await page.waitForTimeout(900); } else if (y.startsWith('click:')) { await page.click(y.slice(6)); await page.waitForTimeout(1600); } else { await page.evaluate(v=>{ const n = v.endsWith('%') ? (document.documentElement.scrollHeight-innerHeight)*parseFloat(v)/100 : +v; scrollTo(0,n)}, y); await page.waitForTimeout(900); } const f = out.replace(/\.png$/, `-${y.replace(/[^a-z0-9]/gi,'')}.png`); await page.screenshot({ path: f }); console.log('saved', f); } console.log(errors.length? 'errors:\n'+errors.join('\n') : 'no errors'); await browser.close();