Files
doormile_react/v.mjs
2026-06-06 13:55:33 +05:30

23 lines
1.3 KiB
JavaScript

import { chromium } from 'playwright-core';
const exe = process.env.HOME + '/Library/Caches/ms-playwright/chromium-1223/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing';
const browser = await chromium.launch({ executablePath: exe });
const page = await browser.newPage({ viewport: { width: 390, height: 760 }, deviceScaleFactor: 2 });
// keep the loader on screen long enough: throttle nothing, just capture during initial window
const resp = page.goto('http://localhost:3000/contact', { waitUntil: 'commit' }).catch(()=>{});
// poll quickly for the loader + logo box while visible
let measured = null;
for (let i=0;i<40;i++){
try {
const m = await page.evaluate(()=>{
const loader=document.querySelector('.dm-loader'); const logo=document.querySelector('.dm-loader__logo');
if(!loader||!logo) return null;
const r=logo.getBoundingClientRect();
return { vw:innerWidth, logoLeft:Math.round(r.left), logoRight:Math.round(r.right), logoW:Math.round(r.width), centerOffset:Math.round((r.left+r.width/2)-(innerWidth/2)) };
});
if(m){ measured=m; if(i===2){ await page.screenshot({path:'/tmp/loader.png'}); } }
} catch(e){}
await page.waitForTimeout(40);
}
console.log(JSON.stringify(measured));
await browser.close();