42a4a4634b
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012qRErfCoiTkvDK9N5XHbzb
39 lines
2.1 KiB
JavaScript
39 lines
2.1 KiB
JavaScript
const puppeteer = require('puppeteer');
|
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
async function items(p) {
|
|
return p.$$eval('.lang-globe-item', as => as.map(a => ({text: a.textContent, href: a.getAttribute('href'), cur: a.getAttribute('aria-current'),
|
|
vis: a.offsetParent !== null, r: (b => [Math.round(b.left), Math.round(b.right)])(a.getBoundingClientRect())})));
|
|
}
|
|
(async () => {
|
|
const b = await puppeteer.launch({args: ['--no-sandbox']});
|
|
for (const js of [true, false]) {
|
|
for (const [w, h] of [[1280, 800], [376, 812]]) {
|
|
for (const [u, tag] of [['https://felhom.eu/', 'hu'], ['https://felhom.eu/en/', 'en']]) {
|
|
const p = await b.newPage();
|
|
await p.setJavaScriptEnabled(js);
|
|
await p.setViewport({width: w, height: h});
|
|
await p.goto(u, {waitUntil: 'networkidle2', timeout: 60000});
|
|
const name = `${tag}-${w}-${js ? 'js' : 'nojs'}`;
|
|
const closed = await p.$eval('details.lang-globe', d => d.open);
|
|
if (w < 900) {
|
|
if (!js) { console.log(name, 'phone menu needs JavaScript (the three-line button is scripted); skipped'); await p.close(); continue; }
|
|
await p.click('#hamburger'); await sleep(500);
|
|
}
|
|
await p.click('summary.lang-globe-btn'); await sleep(300);
|
|
const open = await p.$eval('details.lang-globe', d => d.open);
|
|
const it = await items(p);
|
|
const scroll = await p.evaluate(() => [window.innerWidth, document.documentElement.scrollWidth]);
|
|
await p.screenshot({path: `/out/${name}.png`});
|
|
console.log(name, JSON.stringify({openBefore: closed, openAfterClick: open, items: it, viewport_scroll: scroll}));
|
|
for (const i of it) {
|
|
const q = await b.newPage(); await q.setJavaScriptEnabled(js);
|
|
const r = await q.goto(new URL(i.href, u).href, {waitUntil: 'domcontentloaded'});
|
|
console.log(' ', i.text, '->', q.url(), r.status(), await q.$eval('html', e => e.lang)); await q.close();
|
|
}
|
|
await p.close();
|
|
}
|
|
}
|
|
}
|
|
await b.close();
|
|
})().catch(e => { console.error(e); process.exit(1); });
|