This commit is contained in:
Felix Klement committed 2026-09-18 16:04:05 +02:00
commit 4cda1ca41b
72 files changed
+8169

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
import sharp from 'sharp';
import { readdirSync } from 'node:fs';
import { join } from 'node:path';
const [,, dir, out, colsArg = '4', wArg = '360'] = process.argv;
const cols = Number(colsArg), w = Number(wArg), h = Math.round(w * 0.66);
const files = readdirSync(dir).filter(f => /\.(jpe?g|png|webp)$/i.test(f)).sort();
const tiles = [];
for (const [i, f] of files.entries()) {
try {
const buf = await sharp(join(dir, f)).resize(w, h, { fit: 'cover' }).toBuffer();
const label = Buffer.from(`<svg width="${w}" height="24"><rect width="${w}" height="24" fill="black" opacity="0.6"/><text x="6" y="17" font-family="sans-serif" font-size="14" fill="white">${i}: ${f.slice(0, 40)}</text></svg>`);
const tile = await sharp(buf).composite([{ input: label, top: h - 24, left: 0 }]).toBuffer();
tiles.push({ input: tile, left: (i % cols) * w, top: Math.floor(i / cols) * h });
} catch (e) { console.error('skip', f, e.message); }
}
const rows = Math.ceil(tiles.length / cols);
await sharp({ create: { width: cols * w, height: rows * h, channels: 3, background: '#222' } }).composite(tiles).jpeg({ quality: 80 }).toFile(out);
console.log('wrote', out, files.length, 'images');
+19
View File
@@ -0,0 +1,19 @@
import { chromium } from 'playwright';
const [,, url, prefix, width = '1440', height = '900', max = '12'] = process.argv;
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: Number(width), height: Number(height) } });
await page.goto(url, { waitUntil: 'networkidle', timeout: 60000 });
// trigger lazy loading by scrolling through
const total = await page.evaluate(() => document.documentElement.scrollHeight);
for (let y = 0; y < total; y += 600) { await page.evaluate((y) => window.scrollTo(0, y), y); await page.waitForTimeout(150); }
await page.evaluate(() => window.scrollTo(0, 0));
await page.waitForTimeout(800);
const h = Number(height);
const n = Math.min(Number(max), Math.ceil(total / h));
for (let i = 0; i < n; i++) {
await page.evaluate((y) => window.scrollTo(0, y), i * h);
await page.waitForTimeout(700);
await page.screenshot({ path: `${prefix}-${String(i).padStart(2, '0')}.png`, fullPage: false });
}
console.log('total height', total, 'shots', n);
await browser.close();
+12
View File
@@ -0,0 +1,12 @@
import { chromium } from 'playwright';
const [,, url, out, width = '1440', full = 'true'] = process.argv;
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: Number(width), height: 900 }, deviceScaleFactor: 1 });
await page.goto(url, { waitUntil: 'networkidle', timeout: 60000 });
const total = await page.evaluate(() => document.documentElement.scrollHeight);
for (let y = 0; y < total; y += 500) { await page.evaluate((y) => window.scrollTo(0, y), y); await page.waitForTimeout(120); }
await page.evaluate(() => window.scrollTo(0, 0));
await page.waitForTimeout(1200);
await page.screenshot({ path: out, fullPage: full === 'true' });
await browser.close();
console.log('saved', out);
+17
View File
@@ -0,0 +1,17 @@
import { chromium } from 'playwright';
const [,, url, out] = process.argv;
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(url, { waitUntil: 'networkidle' });
const tabs = page.locator('[role="tab"]');
await tabs.nth(0).focus();
await page.keyboard.press('ArrowDown');
await page.waitForTimeout(500);
const selected = await page.evaluate(() => Array.from(document.querySelectorAll('[role="tab"]')).map(t => t.getAttribute('aria-selected')));
const activeImg = await page.evaluate(() => Array.from(document.querySelectorAll('[data-image]')).map(p => p.hasAttribute('data-active')));
const focused = await page.evaluate(() => document.activeElement?.textContent?.trim());
console.log({ selected, activeImg, focused });
await page.locator('#sectors').scrollIntoViewIfNeeded();
await page.waitForTimeout(600);
await page.screenshot({ path: out, fullPage: false });
await browser.close();