Files
vbb/tools/kit-art.mjs
martbost 43e8dac257 Promo kit: add 336x280 (Large box) for every angle (Marty 2026-11-16, Network Ad Space gaps)
New kit shapes rendered from HTML in the site's own look by tools/kit-art.mjs (a shape list now renders only those shapes and leaves the other art alone). Listed in promokit.js SHAPES, so /promote, /api/promo-kit and InstantAdPay's Network sites tab show them. Smoke test counts updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 04:56:15 -06:00

222 lines
22 KiB
JavaScript

// Promo kit art for Downline Banners and Viral Banner Blitz (2026-11-14). Renders every creative from HTML with Playwright so
// the text is crisp, at the exact pixel size of each slot. Same file in both repos (banner-line/app/tools, vbb/app/tools).
// node tools/kit-art.mjs dlb|vbb|all [shape,shape...] (a shape list renders only those shapes, e.g. panel,pillar)
// Env DLB_APP / VBB_APP = the app folder to read the mark from and write into (default the repos under D:/Projects/HighRisk).
// Shapes per site: DLB also has pillar (120x600, Marty 2026-11-16); panel (336x280) on both.
// Output: <app>/public/art/kit/<site>-<angle>-<shape>.png. Neutral names on purpose: no IAB size tokens, no "banner"/"ad"
// (EasyList hides those). The copy here must match the facts in each app (DLB SPEC.md + contract, VBB config.js + how.html).
import { pathToFileURL } from 'url';
import fs from 'fs';
import path from 'path';
const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright/index.js';
const pwm = await import(pathToFileURL(PW).href); const chromium = pwm.chromium || (pwm.default && pwm.default.chromium);
const ROOT = 'D:/Projects/HighRisk';
const SHAPES = { tile: [125, 125], strip: [468, 60], leader: [728, 90], box: [300, 250], panel: [336, 280], tower: [160, 600], pillar: [120, 600], social: [1200, 630], square: [1080, 1080] };
const SITE_SHAPES = { dlb: Object.keys(SHAPES), vbb: Object.keys(SHAPES).filter(k => k !== 'pillar') };
const APPS = { dlb: process.env.DLB_APP || ROOT + '/banner-line/app', vbb: process.env.VBB_APP || ROOT + '/vbb/app' };
const SITES = {
dlb: {
out: APPS.dlb + '/public/art/kit', domain: 'downlinebanners.com', name: ['Downline', 'Banners'],
mark: fs.readFileSync(APPS.dlb + '/public/art/mark.svg', 'utf8'),
fonts: 'family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Inter:wght@500;600;700',
angles: {
spot: { eyebrow: '$5 spot', h1: 'A $5 spot.', h2: '300 guaranteed views.', line: 'A $5 spot. 300 guaranteed views.', sub: 'Your banner on the board, paid on-chain on Polygon.', cta: 'Get a spot', tA: '$5 spot', tB: '300 views', chips: ['$5 spot', '300 guaranteed views', 'Paid on-chain'] },
line: { eyebrow: '10 levels', h1: '10 levels pay', h2: 'as spots sell after yours.', line: '10 levels pay as spots sell after yours', sub: 'Sponsor 30%. Each of 10 levels 5.5%. Fixed in the contract.', cta: 'See the line', tA: '10 levels', tB: 'paid on-chain', chips: ['Sponsor 30%', '10 levels x 5.5%', 'Splits fixed on-chain'] },
instant: { eyebrow: 'Nothing to withdraw', h1: 'No withdrawals.', h2: 'Paid in the same transaction.', line: 'No withdrawals. Paid in the same transaction.', sub: 'A Polygon contract splits every $5 spot the moment it sells.', cta: 'See how', tA: 'No withdrawals', tB: 'paid same tx', chips: ['Same-transaction payouts', 'Verified contract', '$5 spot'] }
}
},
vbb: {
out: APPS.vbb + '/public/art/kit', domain: 'viralbannerblitz.com', name: ['Viral Banner', 'Blitz'],
mark: fs.readFileSync(APPS.vbb + '/public/art/mark.svg', 'utf8'),
fonts: 'family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@500;700&family=Space+Mono:wght@700',
angles: {
free: { eyebrow: 'Free daily post', h1: 'Post a banner', h2: 'free every day.', line: 'Post a banner free every day', sub: 'InstantAdPay and LinkSpin members get a free post credit each day they sign in.', cta: 'Post yours', tA: 'FREE', tB: 'daily post', chips: ['125x125 banners', 'Free daily post', 'No subscription'] },
loop: { eyebrow: 'Real visitors only', h1: 'Every visitor', h2: 'pushes the loop.', line: 'Every visitor pushes the loop', sub: 'Real visitors move every banner forward. Ride out and earn network ad views.', cta: 'Join the loop', tA: 'Every visit', tB: 'moves it', chips: ['Verified visitors', 'Bots do not count', 'Network ad views'] },
prize: { eyebrow: 'Weekly leaderboards', h1: 'Send visitors.', h2: 'Climb the weekly board.', line: 'Weekly prizes, at least $20 a week', sub: 'Prize pot of at least $20 a week, paid in POL to the top three on each board.', cta: 'See the leaders', tA: 'Weekly', tB: 'prizes', chips: ['At least $20 a week', 'Paid in POL', 'Two leaderboards'] }
}
}
};
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
// shrink every .fit element until its text fits its box (one line or the box height); .wfit (wrapping) until its longest word fits
const FIT = `<script>window.__fit=()=>{document.querySelectorAll('.fit').forEach(el=>{let s=parseFloat(getComputedStyle(el).fontSize);let n=0;while((el.scrollWidth>el.clientWidth+1||el.scrollHeight>el.clientHeight+s*0.2)&&s>6&&n++<200){s-=0.5;el.style.fontSize=s+'px';}});document.querySelectorAll('.wfit').forEach(el=>{let s=parseFloat(getComputedStyle(el).fontSize);let n=0;while(el.scrollWidth>el.clientWidth+1&&s>8&&n++<100){s-=0.5;el.style.fontSize=s+'px';}});};</script>`;
function dlbCss() {
return `
:root{--bg:#0b0913;--ink:#f3f1fa;--muted:#a29cbc;--lime:#c6f432;--mint:#7ef0c8;--cyan:#6fd8ff;--vio:#9b7bff}
*{box-sizing:border-box;margin:0;padding:0}
html,body{width:var(--w);height:var(--h);overflow:hidden}
body{font-family:Inter,system-ui,sans-serif;color:var(--ink);background:
radial-gradient(55% 70% at 18% 20%,rgba(155,123,255,.32),transparent 70%),radial-gradient(45% 60% at 85% 85%,rgba(198,244,50,.16),transparent 70%),
linear-gradient(160deg,#1c1733 0%,#0b0913 70%);position:relative}
body::after{content:"";position:absolute;inset:0;border:1px solid rgba(155,123,255,.45);pointer-events:none}
.g{background:linear-gradient(92deg,var(--lime) 5%,var(--mint) 55%,var(--cyan));-webkit-background-clip:text;background-clip:text;color:transparent}
.disp{font-family:"Bricolage Grotesque",system-ui,sans-serif;font-weight:800;letter-spacing:-.03em;line-height:1.02}
.mark svg{width:100%;height:100%;display:block}
.wm{font-family:"Bricolage Grotesque";font-weight:800;letter-spacing:-.03em;white-space:nowrap}
.eb{display:inline-block;font-weight:700;text-transform:uppercase;letter-spacing:.12em;color:var(--lime);border:1.5px solid var(--lime);border-radius:999px;white-space:nowrap}
.cta{display:inline-flex;align-items:center;justify-content:center;font-family:"Bricolage Grotesque";font-weight:800;color:#0b0913;background:linear-gradient(92deg,var(--lime),var(--mint));border-radius:999px;white-space:nowrap}
.chip{display:inline-block;color:var(--muted);border:1.5px solid rgba(162,156,188,.35);border-radius:999px;font-weight:600;white-space:nowrap}
.chip:first-child{color:var(--lime);border-color:var(--lime)}
.sub{color:#cfc9e6}
.fit{white-space:nowrap;overflow:hidden;flex:none}
.h .g,.h .hot{width:fit-content;max-width:100%}`;
}
function vbbCss() {
return `
:root{--bg:#fff4dc;--ink:#14121f;--hot:#ff2d87;--sky:#2b59ff;--amber:#ffd400;--mint:#14d9a0;--muted:#4d4862}
*{box-sizing:border-box;margin:0;padding:0}
html,body{width:var(--w);height:var(--h);overflow:hidden}
body{font-family:"DM Sans",system-ui,sans-serif;color:var(--ink);background:var(--bg);position:relative;
background-image:radial-gradient(rgba(255,45,135,.18) 1.4px,transparent 1.6px),radial-gradient(rgba(43,89,255,.13) 1.4px,transparent 1.6px);
background-size:22px 22px,22px 22px;background-position:0 0,11px 11px}
body::after{content:"";position:absolute;inset:0;border:var(--edge,3px) solid var(--ink);pointer-events:none}
.disp{font-family:"Bricolage Grotesque",system-ui,sans-serif;font-weight:800;letter-spacing:-.03em;line-height:1}
.hot{color:var(--hot);-webkit-text-stroke:var(--stroke,1px) var(--ink);text-shadow:var(--ts,3px) var(--ts,3px) 0 var(--amber)}
.mark svg{width:100%;height:100%;display:block}
.wm{font-family:"Bricolage Grotesque";font-weight:800;letter-spacing:-.03em;white-space:nowrap}
.wm b{color:var(--hot);-webkit-text-stroke:.6px var(--ink)}
.eb{display:inline-block;font-family:"Space Mono",monospace;font-weight:700;text-transform:uppercase;letter-spacing:.1em;background:var(--mint);border:2.5px solid var(--ink);border-radius:999px;box-shadow:3px 3px 0 var(--ink);transform:rotate(-1.5deg);white-space:nowrap}
.cta{display:inline-flex;align-items:center;justify-content:center;font-family:"Bricolage Grotesque";font-weight:800;color:#fff;background:var(--hot);border:2.5px solid var(--ink);border-radius:12px;box-shadow:4px 4px 0 var(--ink);white-space:nowrap}
.chip{display:inline-block;font-weight:700;border:2.5px solid var(--ink);border-radius:999px;background:#fff;box-shadow:3px 3px 0 var(--ink);white-space:nowrap}
.chip:nth-child(1){background:var(--amber)} .chip:nth-child(2){background:#dbe4ff} .chip:nth-child(3){background:#c9f7e6}
.sub{color:var(--muted)}
.fit{white-space:nowrap;overflow:hidden}
.tiles{position:absolute;display:grid;grid-template-columns:repeat(3,1fr);gap:var(--tg,14px)}
.tiles i{display:block;aspect-ratio:1;border:3px solid var(--ink);border-radius:12px;box-shadow:5px 5px 0 var(--ink)}`;
}
const VBB_TILE_COLORS = ['#ff2d87', '#2b59ff', '#ffd400', '#14d9a0', '#ffffff', '#ff2d87', '#14d9a0', '#2b59ff', '#ffffff', '#ffd400', '#2b59ff', '#ff2d87'];
const vTiles = (n, rot) => '<div class="tiles">' + Array.from({ length: n }, (_, i) => '<i style="background:' + VBB_TILE_COLORS[i % 12] + ';transform:rotate(' + (((i * 37) % 7) - 3) * (rot || 1) + 'deg)"></i>').join('') + '</div>';
function body(site, a, shape) {
const S = SITES[site]; const m = '<div class="mark">' + S.mark + '</div>'; const d = site === 'dlb';
const wm = d ? '<span class="wm">Downline <span class="g">Banners</span></span>' : '<span class="wm">Viral Banner <b>Blitz</b></span>';
const h2 = d ? '<span class="g">' + esc(a.h2) + '</span>' : '<span class="hot">' + esc(a.h2) + '</span>';
const chips = a.chips.map(c => '<span class="chip">' + esc(c) + '</span>').join('');
switch (shape) {
case 'tile': return `<style>
.t{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:8px;gap:3px}
.t .mark{width:30px;height:30px;margin-bottom:3px}
.t .a{font-size:27px;width:109px;line-height:1.05} .t .b{font-size:15px;width:109px;font-weight:800;font-family:"Bricolage Grotesque"}
.t .c{font-size:9.5px;font-weight:700;width:109px;opacity:.85;margin-top:2px}
${d ? '' : 'body{--edge:3px} .t .a{color:var(--ink)} .t .b{display:inline-block;width:auto;background:var(--hot);color:#fff;border:2px solid var(--ink);border-radius:8px;padding:1px 7px;box-shadow:2px 2px 0 var(--ink);transform:rotate(-2deg)}'}
</style><div class="t">${m}<div class="a disp fit">${esc(a.tA)}</div><div class="b fit ${d ? 'g' : ''}">${esc(a.tB)}</div><div class="c fit">${esc(S.domain)}</div></div>`;
case 'strip': return `<style>
.s{position:absolute;inset:0;display:flex;align-items:center;gap:10px;padding:0 10px}
.s .mark{width:40px;height:40px;flex:none}
.s .mid{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.s .h{font-size:19px;width:100%} .s .w{font-size:11px;font-weight:600;opacity:.8;width:100%}
.s .cta{font-size:13px;padding:8px 12px;flex:none} ${d ? '' : 'body{--edge:2.5px} .s .cta{box-shadow:2px 2px 0 var(--ink);border-width:2px;border-radius:9px}'}
</style><div class="s">${m}<div class="mid"><div class="h disp fit">${esc(a.line)}</div><div class="w fit">${esc(S.name.join(' '))} &middot; ${esc(S.domain)}</div></div><span class="cta">${esc(a.cta)}</span></div>`;
case 'leader': return `<style>
.l{position:absolute;inset:0;display:flex;align-items:center;gap:16px;padding:0 18px}
.l .mark{width:58px;height:58px;flex:none}
.l .mid{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
.l .h{font-size:28px;width:100%} .l .w{font-size:13.5px;width:100%}
.l .cta{font-size:17px;padding:12px 20px;flex:none} ${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px}'}
</style><div class="l">${m}<div class="mid"><div class="h disp fit">${esc(a.h1)} ${h2}</div><div class="w sub fit">${esc(a.sub)}</div></div><span class="cta">${esc(a.cta)}</span></div>`;
case 'box': return `<style>
.b{position:absolute;inset:0;display:flex;flex-direction:column;padding:16px 18px;gap:9px}
.b .top{display:flex;align-items:center;gap:8px} .b .mark{width:34px;height:34px;flex:none} .b .wm{font-size:17px}
.b .eb{font-size:10px;padding:4px 9px;align-self:flex-start}
.b .h{font-size:28px;width:100%;white-space:normal;max-height:62px} .b .h span{display:block;white-space:nowrap}
.b .sub{font-size:12.5px;line-height:1.35}
.b .cta{font-size:15px;padding:10px 16px;margin-top:auto;align-self:flex-start} ${d ? '' : 'body{--edge:3px;--stroke:.5px;--ts:1.5px}'}
</style><div class="b"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2.replace('<span class="', '<span class="') }</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)} &rarr;</span></div>`;
case 'panel': return `<style>
.b{position:absolute;inset:0;display:flex;flex-direction:column;padding:18px 20px;gap:10px}
.b .top{display:flex;align-items:center;gap:9px} .b .mark{width:38px;height:38px;flex:none} .b .wm{font-size:19px}
.b .eb{font-size:11px;padding:4px 10px;align-self:flex-start}
.b .h{font-size:31px;width:100%;white-space:normal;max-height:68px} .b .h span{display:block;white-space:nowrap}
.b .sub{font-size:14px;line-height:1.35}
.b .bot{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:10px}
.b .cta{font-size:16px;padding:10px 17px} .b .dom{font-size:11.5px;font-weight:700;opacity:.8;white-space:nowrap}
${d ? '' : 'body{--edge:3px;--stroke:.5px;--ts:1.5px}'}
</style><div class="b"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><div class="bot"><span class="cta">${esc(a.cta)} &rarr;</span><span class="dom">${esc(S.domain)}</span></div></div>`;
case 'pillar': return `<style>
.v{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;text-align:center;padding:18px 8px 16px;gap:11px}
.v .mark{width:52px;height:52px} .v .wm{font-size:15px;white-space:normal;line-height:1.05}
.v .eb{font-size:8px;padding:4px 6px;letter-spacing:.06em;max-width:104px;white-space:normal;line-height:1.2}
.v .h{font-size:24px;line-height:1.05;white-space:normal;width:106px;overflow:hidden;overflow-wrap:normal} .v .h span{display:block}
.v .sub{font-size:12px;line-height:1.38}
.v .cta{font-size:13px;padding:9px 11px;margin-top:auto} .v .dom{font-size:9px;font-weight:700;opacity:.8}
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px} .v .wm b{display:block}'}
</style><div class="v">${m}${d ? '<span class="wm">Downline<br><span class="g">Banners</span></span>' : '<span class="wm">Viral Banner <b>Blitz</b></span>'}<span class="eb">${esc(a.eyebrow)}</span><div class="h disp wfit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)}</span><div class="dom">${esc(S.domain)}</div></div>`;
case 'tower': return `<style>
.v{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;text-align:center;padding:22px 12px 20px;gap:12px}
.v .mark{width:64px;height:64px} .v .wm{font-size:17px;white-space:normal;line-height:1.05}
.v .eb{font-size:9px;padding:4px 8px}
.v .h{font-size:30px;line-height:1.05;white-space:normal;width:140px;overflow-wrap:normal} .v .h span{display:block}
.v .sub{font-size:13px;line-height:1.4}
.v .cta{font-size:15px;padding:11px 14px;margin-top:auto} .v .dom{font-size:10.5px;font-weight:700;opacity:.8}
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px} .v .wm b{display:block}'}
</style><div class="v">${m}${d ? '<span class="wm">Downline<br><span class="g">Banners</span></span>' : '<span class="wm">Viral Banner <b>Blitz</b></span>'}<span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)}</span><div class="dom">${esc(S.domain)}</div></div>`;
case 'social': return d ? `<style>
.o{position:absolute;inset:0;padding:64px 80px;display:flex;flex-direction:column}
.o .top{display:flex;align-items:center;gap:26px} .o .mark{width:118px;height:118px} .o .wm{font-size:60px}
.o .eb{font-size:17px;padding:8px 16px;align-self:flex-start;margin:44px 0 18px}
.o .h{font-size:78px;width:1040px} .o .h span{display:block;white-space:nowrap}
.o .sub{font-size:27px;margin-top:20px;max-width:980px}
.o .chips{margin-top:auto;display:flex;gap:14px} .o .chip{font-size:22px;padding:10px 20px}
</style><div class="o"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><div class="chips">${chips}<span class="chip">${esc(S.domain)}</span></div></div>`
: `<style>
body{--edge:0px}
.o{position:absolute;inset:0;padding:64px 0 56px 72px;display:flex;flex-direction:column;width:690px}
.o .eb{font-size:17px;padding:9px 18px;align-self:flex-start}
.o .h{font-size:76px;margin-top:30px;width:620px;white-space:normal;--stroke:2px;--ts:5px} .o .h span{display:block;white-space:nowrap}
.o .sub{font-size:26px;margin-top:24px;line-height:1.35;color:var(--ink)}
.o .bot{margin-top:auto;display:flex;align-items:center;gap:16px} .o .mark{width:62px;height:62px} .o .dom{font:800 32px "Bricolage Grotesque"}
.tiles{right:-30px;top:84px;width:430px;--tg:16px} .tiles i{border-radius:14px}
</style>${vTiles(12)}<div class="o"><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><div class="bot">${m}<span class="dom">${esc(S.domain)}</span></div></div>`;
case 'square': return d ? `<style>
.q{position:absolute;inset:0;padding:84px 86px;display:flex;flex-direction:column}
.q .top{display:flex;align-items:center;gap:26px} .q .mark{width:120px;height:120px} .q .wm{font-size:60px}
.q .eb{font-size:22px;padding:10px 20px;align-self:flex-start;margin:96px 0 26px}
.q .h{font-size:104px;width:908px;white-space:normal} .q .h span{display:block}
.q .sub{font-size:34px;line-height:1.35;margin-top:34px}
.q .chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:14px} .q .chip{font-size:26px;padding:12px 22px}
.q .dom{font:800 40px "Bricolage Grotesque";margin-top:26px}
</style><div class="q"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><div class="chips">${chips}</div><div class="dom g">${esc(S.domain)}</div></div>`
: `<style>
body{--edge:0px}
.q{position:absolute;inset:0;padding:80px 84px;display:flex;flex-direction:column}
.q .top{display:flex;align-items:center;gap:20px} .q .mark{width:96px;height:96px} .q .wm{font-size:50px}
.q .eb{font-size:22px;padding:11px 22px;align-self:flex-start;margin-top:64px}
.q .h{font-size:104px;margin-top:36px;white-space:normal;--stroke:2.5px;--ts:6px} .q .h span{display:block}
.q .sub{font-size:33px;margin-top:30px;line-height:1.35;color:var(--ink);max-width:880px}
.q .chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:16px} .q .chip{font-size:26px;padding:12px 22px}
.tiles{right:-50px;top:-40px;width:330px;--tg:14px;grid-template-columns:repeat(3,1fr)}
</style>${vTiles(6)}<div class="q"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><div class="chips">${chips}<span class="chip" style="background:var(--hot);color:#fff">${esc(S.domain)}</span></div></div>`;
}
}
function page(site, angle, shape) {
const S = SITES[site]; const [w, h] = SHAPES[shape];
return `<!doctype html><html><head><meta charset="utf-8"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?${S.fonts}&display=block">
<style>:root{--w:${w}px;--h:${h}px}${site === 'dlb' ? dlbCss() : vbbCss()}</style>${FIT}</head><body>${body(site, S.angles[angle], shape)}</body></html>`;
}
const which = process.argv[2] || 'all';
const only = process.argv[3] ? process.argv[3].split(',') : null;
const browser = await chromium.launch();
const made = []; let file0;
for (const site of Object.keys(SITES)) {
if (which !== 'all' && which !== site) continue;
const S = SITES[site]; fs.mkdirSync(S.out, { recursive: true });
for (const angle of Object.keys(S.angles)) for (const shape of SITE_SHAPES[site]) {
if (only && !only.includes(shape)) continue;
const [w, h] = SHAPES[shape];
const pg = await browser.newPage({ viewport: { width: w, height: h }, deviceScaleFactor: 1 });
await pg.setContent(page(site, angle, shape), { waitUntil: 'networkidle' });
if (process.env.DBG) console.log(file0 = shape, await pg.evaluate(async () => { await document.fonts.ready; return [...document.querySelectorAll('.fit')].map(el => [el.className, el.scrollWidth, el.clientWidth, el.scrollHeight, el.clientHeight]); }));
await pg.evaluate(async () => { await document.fonts.ready; window.__fit(); });
const file = path.join(S.out, site + '-' + angle + '-' + shape + '.png');
await pg.screenshot({ path: file, clip: { x: 0, y: 0, width: w, height: h } });
await pg.close(); made.push(file);
}
}
await browser.close();
console.log(made.length + ' files\n' + made.join('\n'));