← back to Re Flyer Aggregator

scripts/record-live.cjs

21 lines

const { chromium } = require('/Users/macstudio3/Projects/nationalrealestate/node_modules/playwright');
(async () => {
  const out = require('path').join(process.cwd(), 'out');
  const browser = await chromium.launch({ args: ['--use-gl=angle','--use-angle=swiftshader','--enable-webgl','--ignore-gpu-blocklist'] });
  const ctx = await browser.newContext({ viewport:{width:1280,height:800}, recordVideo:{ dir: out, size:{width:1280,height:800} } });
  const page = await ctx.newPage();
  await page.goto('http://127.0.0.1:9862/live.html', { waitUntil:'domcontentloaded' });
  await page.waitForTimeout(6500);                         // bars drop in
  for (const m of ['market','source','type']) { await page.selectOption('#mode', m); await page.waitForTimeout(2600); }
  // click a bar to open the drill (sweep the canvas via the page's own handler)
  await page.evaluate(() => { const cv=document.querySelector('canvas'),r=cv.getBoundingClientRect();
    for(let x=r.left+40;x<r.right-40;x+=20)for(let y=r.top+120;y<r.bottom-60;y+=20){
      cv.dispatchEvent(new MouseEvent('click',{clientX:x,clientY:y,bubbles:true}));
      if(document.getElementById('drill').classList.contains('open'))return; } });
  await page.waitForTimeout(3500);                          // show drill panel
  await page.click('#drill .x').catch(()=>{});              // close it
  await page.waitForTimeout(1500);
  await ctx.close(); await browser.close();
  console.log('recorded to out/*.webm');
})();