2026-10-02 00:47:49 -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 00:47:49 -04:00
( async ( ) => { const b = await chromium . launch ( { args : [ '--no-sandbox' ] } ) ; const c = await b . newContext ( { viewport : { width : 1920 , height : 1080 } } ) ;
2026-10-06 09:41:27 -04:00
await c . addCookies ( [ { name : 'dragonflight.sid' , value : process . env . DF _SESSION _COOKIE , domain : 'mediacmdr.com' , path : '/' , httpOnly : true , secure : true } ] ) ;
2026-10-02 00:47:49 -04:00
const p = await c . newPage ( ) ; await p . goto ( 'https://mediacmdr.com/#home' , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 3000 ) ;
const ct = ( s ) => p . evaluate ( s => { const e = [ ... document . querySelectorAll ( 'button,[role=tab],a,div,span' ) ] . filter ( x => x . offsetHeight > 0 && x . children . length < 4 ) . find ( x => new RegExp ( s , 'i' ) . test ( ( x . innerText || '' ) . trim ( ) ) ) ; e && e . click ( ) ; return ! ! e } , s ) ;
await ct ( '^Downloads' ) ; await p . waitForTimeout ( 2000 ) ; await ct ( '^Desktop apps' ) ; await p . waitForTimeout ( 2000 ) ;
console . log ( await p . evaluate ( ( ) => { const d = document . querySelector ( '[role=dialog],[class*=modal]' ) ; return d ? d . innerText : 'nodialog' } ) ) ;
console . log ( JSON . stringify ( await p . evaluate ( ( ) => [ ... document . querySelectorAll ( '[role=dialog] a,[class*=modal] a' ) ] . map ( a => a . getAttribute ( 'href' ) ) ) ) ) ;
await b . close ( ) } ) ( ) ;