21 lines
1.5 KiB
JavaScript
21 lines
1.5 KiB
JavaScript
import { chromium } from 'playwright';
|
|
/* Reports where the chevron hint sits at the first snap and whether anything covers it. */
|
|
const [,, url, width = '1440', height = '900'] = 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' });
|
|
const snaps = await page.evaluate(() => Array.from(document.querySelectorAll('[data-deck-snap]')).map((a) => Math.round(a.getBoundingClientRect().top + window.scrollY - parseFloat(getComputedStyle(a).scrollMarginTop))));
|
|
await page.evaluate((y) => window.scrollTo(0, y), snaps[0]);
|
|
await page.waitForTimeout(800);
|
|
const info = await page.evaluate(() => {
|
|
const h = document.querySelector('[data-deck-hint]');
|
|
const r = h.getBoundingClientRect();
|
|
const cs = getComputedStyle(h);
|
|
const svg = h.querySelector('svg').getBoundingClientRect();
|
|
const atPoint = document.elementFromPoint(window.innerWidth / 2, window.innerHeight - 10);
|
|
const next = document.querySelectorAll('[data-deck-card]')[1].getBoundingClientRect();
|
|
return { hint: { top: r.top, bottom: r.bottom, h: r.height }, svg: { top: svg.top, bottom: svg.bottom }, position: cs.position, display: cs.display, bottom: cs.bottom, zIndex: cs.zIndex, opacity: cs.opacity, atPoint: atPoint && (atPoint.tagName + '.' + atPoint.className), nextCardTop: next.top, innerHeight: window.innerHeight };
|
|
});
|
|
console.log(JSON.stringify(info, null, 1));
|
|
await browser.close();
|