media-command-guide/dl-text.js
zgaetano 0c9b9d98fb security: read session cookie from DF_SESSION_COOKIE env var
The dragonflight.sid cookie was hardcoded in 12 Playwright capture scripts.
Read it from the environment instead, fail fast when unset, and add
.env.example /.env gitignore. The leaked session has been revoked.
2026-10-06 09:41:27 -04:00

10 lines
1.3 KiB
JavaScript

const { chromium } = require('playwright');
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); }
(async()=>{const b=await chromium.launch({args:['--no-sandbox']});const c=await b.newContext({viewport:{width:1920,height:1080}});
await c.addCookies([{name:'dragonflight.sid',value:process.env.DF_SESSION_COOKIE,domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]);
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()})();