2026-10-02 07:57:00 -04:00
const { chromium } = require ( 'playwright' ) ;
2026-10-06 09:41:27 -04:00
if ( ! process . env . DF _SESSION _COOKIE ) { console . error ( 'DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.' ) ; process . exit ( 1 ) ; }
2026-10-02 07:57:00 -04:00
const OUT = '/home/zgaetano/media-command-guide/screenshots' ;
2026-10-06 09:41:27 -04:00
const COOKIE = process . env . DF _SESSION _COOKIE ;
2026-10-02 07:57:00 -04:00
const esc = p => p . keyboard . press ( 'Escape' ) ;
( async ( ) => {
const b = await chromium . launch ( { args : [ '--no-sandbox' , '--autoplay-policy=no-user-gesture-required' ] } ) ;
const c = await b . newContext ( { viewport : { width : 1920 , height : 1080 } } ) ;
await c . addCookies ( [ { name : 'dragonflight.sid' , value : COOKIE , domain : 'mediacmdr.com' , path : '/' , httpOnly : true , secure : true } ] ) ;
const p = await c . newPage ( ) ;
await p . goto ( 'https://mediacmdr.com/#recorders' , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 4000 ) ;
// Dense list
await p . click ( 'button[title^="Dense list"]' ) . catch ( ( ) => { } ) ; await p . waitForTimeout ( 2000 ) ;
await p . screenshot ( { path : ` ${ OUT } /05-recorders-dense.png ` } ) ;
// Cards with previews
await p . click ( 'button[title^="Cards"]' ) . catch ( e => console . log ( 'cards btn' , e . message ) ) ; await p . waitForTimeout ( 9000 ) ;
await p . screenshot ( { path : ` ${ OUT } /05-recorders-cards.png ` } ) ;
// Scroll to a node group that has signal, take a tighter crop
const sig = await p . evaluate ( ( ) => { const el = [ ... document . querySelectorAll ( '.recorder-card,[class*=recorder-card]' ) ] . find ( e => ! /NO SIGNAL/ . test ( e . innerText ) && e . offsetHeight > 100 ) ; if ( el ) { el . scrollIntoView ( { block : 'center' } ) ; return el . innerText . replace ( /\s+/g , ' ' ) . slice ( 0 , 120 ) } return null } ) ;
console . log ( 'signal card:' , sig ) ; await p . waitForTimeout ( 5000 ) ;
await p . screenshot ( { path : ` ${ OUT } /05b-recorders-previews.png ` } ) ;
// Configure recorder panel
const n = await p . locator ( 'button[title="Configure recorder"]' ) . count ( ) ; console . log ( 'cfg buttons' , n ) ;
if ( n ) { await p . locator ( 'button[title="Configure recorder"]' ) . first ( ) . click ( ) ; await p . waitForTimeout ( 3000 ) ;
await p . screenshot ( { path : ` ${ OUT } /05d-recorder-configure.png ` } ) ;
console . log ( 'cfg:' , ( await p . evaluate ( ( ) => { const d = document . querySelector ( '[class*=modal],[class*=drawer],[class*=sheet],[role=dialog]' ) ; return d ? d . innerText . replace ( /\n+/g , ' | ' ) . slice ( 0 , 900 ) : 'none' } ) ) ) ;
// scroll inside panel to codec section
await p . evaluate ( ( ) => { const d = document . querySelector ( '[class*=modal] [class*=body],[role=dialog] [class*=body],[class*=drawer]' ) ; if ( d ) d . scrollTop = d . scrollHeight / 2 } ) ; await p . waitForTimeout ( 1000 ) ;
await p . screenshot ( { path : ` ${ OUT } /05e-recorder-configure-codec.png ` } ) ; await esc ( p ) ; }
// Schedule: list view + context menu on an event
await p . goto ( 'https://mediacmdr.com/#schedule' , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 4000 ) ;
for ( const v of [ 'Day' , 'Week' , 'List' ] ) { await p . evaluate ( l => { const x = [ ... document . querySelectorAll ( 'button' ) ] . find ( b => b . innerText . trim ( ) === l ) ; x && x . click ( ) } , v ) ; await p . waitForTimeout ( 2500 ) ; await p . screenshot ( { path : ` ${ OUT } /06-schedule- ${ v . toLowerCase ( ) } .png ` } ) ; }
// Back to Day, go to previous days until an event block exists, right-click it
await p . evaluate ( ( ) => { const x = [ ... document . querySelectorAll ( 'button' ) ] . find ( b => b . innerText . trim ( ) === 'Day' ) ; x && x . click ( ) } ) ; await p . waitForTimeout ( 2000 ) ;
let found = false ;
for ( let i = 0 ; i < 14 && ! found ; i ++ ) {
found = await p . evaluate ( ( ) => { const ev = [ ... document . querySelectorAll ( '[class*=event],[class*=epg-block],[class*=sched-block]' ) ] . find ( e => e . offsetHeight > 10 && e . offsetWidth > 20 && e . innerText . trim ( ) ) ; if ( ! ev ) return false ; const r = ev . getBoundingClientRect ( ) ; ev . dispatchEvent ( new MouseEvent ( 'contextmenu' , { bubbles : true , clientX : r . x + 10 , clientY : r . y + 10 } ) ) ; return ev . innerText . trim ( ) . slice ( 0 , 60 ) } ) ;
if ( ! found ) { await p . evaluate ( ( ) => { const x = [ ... document . querySelectorAll ( 'button' ) ] . find ( b => / ^ ( ‹ | < | Prev | Previous ) $ / . test ( b . innerText . trim ( ) ) || /previous/i . test ( b . title || b . getAttribute ( 'aria-label' ) || '' ) ) ; x && x . click ( ) } ) ; await p . waitForTimeout ( 1800 ) ; }
}
console . log ( 'event ctx:' , found ) ; await p . waitForTimeout ( 1200 ) ;
await p . screenshot ( { path : ` ${ OUT } /06e-schedule-context-menu.png ` } ) ;
await esc ( p ) ;
// Record now + New schedule dialogs (re-take cleanly)
for ( const [ l , f ] of [ [ 'Record now' , '06d-schedule-record-now' ] , [ 'New schedule' , '06b-schedule-new' ] ] ) {
await p . evaluate ( t => { const x = [ ... document . querySelectorAll ( 'button' ) ] . find ( b => b . innerText . trim ( ) === t ) ; x && x . click ( ) } , l ) ; await p . waitForTimeout ( 2500 ) ;
await p . screenshot ( { path : ` ${ OUT } / ${ f } .png ` } ) ;
console . log ( l , ':' , ( await p . evaluate ( ( ) => { const d = document . querySelector ( '[class*=modal],[role=dialog]' ) ; return d ? d . innerText . replace ( /\n+/g , ' | ' ) . slice ( 0 , 500 ) : 'none' } ) ) ) ;
await esc ( p ) ; await p . waitForTimeout ( 800 ) ; }
await b . close ( ) ; } ) ( ) ;