media-command-guide/page-text.js
zgaetano 35e5c133f7 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:56 -04:00

10 lines
1.5 KiB
JavaScript

const { chromium } = require('playwright');const fs=require('fs');
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); }
const R=['home','recorders','schedule','graphics','multiview','projects','library?project=5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f','upload','contribution','youtube','cloud-import','jobs','staging','playout','playout-tria','engineering','applications','users','tokens','containers','logs','audit','cluster','alerts','settings','rundown','playout-schedule','playout-ads'];
(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/',{waitUntil:'networkidle'});const out={};
for(const r of R){await p.evaluate(h=>{location.hash=h},r);await p.waitForTimeout(4000);
out[r]=await p.evaluate(()=>{const m=document.querySelector('main,[class*=content],[class*=page]')||document.body;return m.innerText.replace(/\n{2,}/g,'\n').slice(0,1400)});}
await p.goto('https://mediacmdr.com/editor.html',{waitUntil:'networkidle'});await p.waitForTimeout(4000);out.editor=await p.evaluate(()=>document.body.innerText.slice(0,1000));
fs.writeFileSync('page-text.json',JSON.stringify(out,null,1));await b.close()})();