← back to Rentv Tour

desk-cap.mjs

24 lines

import { chromium } from 'playwright';
const OUT='/Users/macstudio3/Projects/rentv-master-reel/media/captures';
const BASE='https://rentv.agentabrams.com';
const CLEAN_CSS=`#cap-header{position:sticky;top:0;z-index:99999;display:flex;align-items:center;justify-content:space-between;height:64px;padding:0 24px;background:#fff;border-bottom:1px solid #e6eaef;font-family:-apple-system,sans-serif}#cap-header .cap-brand{font-size:23px;font-weight:800;color:#0d1b2a;text-decoration:none}#cap-header .cap-brand span{color:#c0392b}#cap-header button{background:none;border:0;color:#0d1b2a;display:inline-flex;padding:9px}`;
const b=await chromium.launch();
const ctx=await b.newContext({viewport:{width:1440,height:810},deviceScaleFactor:2,httpCredentials:{username:'admin',password:'DW2024!'}});
const p=await ctx.newPage();
const resp=await p.goto(BASE+'/desk',{waitUntil:'networkidle',timeout:45000});
await p.waitForTimeout(2500);
// close any open drawer, then inject clean header hiding only the top header bar
await p.addStyleTag({content:CLEAN_CSS});
await p.evaluate(()=>{
  // close drawer if open
  document.querySelectorAll('.drawer,.scrim').forEach(e=>{e.classList.remove('open','active','show');e.style.display='none';});
  // hide top header only (not the shell content)
  document.querySelectorAll('header.top,.top').forEach(e=>{e.style.display='none';});
  if(!document.getElementById('cap-header')){const bar=document.createElement('div');bar.id='cap-header';bar.innerHTML=`<button><svg width=24 height=24 viewBox="0 0 24 24" fill=none stroke=currentColor stroke-width=2.2 stroke-linecap=round><path d="M3 6h18M3 12h18M3 18h18"/></svg></button><a class=cap-brand href="/">REN<span>TV</span></a><button><svg width=21 height=21 viewBox="0 0 24 24" fill=none stroke=currentColor stroke-width=2><circle cx=12 cy=8 r=3.6/><path d="M4.5 20a7.5 7.5 0 0 1 15 0" stroke-linecap=round/></svg></button>`;document.body.insertBefore(bar,document.body.firstChild)}
  window.scrollTo(0,0);
});
await p.waitForTimeout(500);
await p.screenshot({path:`${OUT}/desk.png`});
console.log('OK desk.png ['+resp.status()+']');
await b.close();