media-command-guide/inspect-library.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

53 lines
2.2 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 browser = await chromium.launch({ headless: true });
const context = await browser.newContext({ viewport: { width: 1920, height: 1080 } });
await context.addCookies([{
name: 'dragonflight.sid',
value: process.env.DF_SESSION_COOKIE,
domain: 'mediacmdr.com',
path: '/',
httpOnly: true,
secure: true
}]);
const page = await context.newPage();
await page.goto('https://mediacmdr.com/', { waitUntil: 'networkidle' });
// Navigate to Library
await page.evaluate(() => {
const items = Array.from(document.querySelectorAll('.nav-item'));
const target = items.find(i => i.innerText.trim().startsWith('Library'));
if (target) target.click();
});
await page.waitForTimeout(4000);
// Check what's rendered in Library
const info = await page.evaluate(() => {
return {
text: document.body.innerText.slice(0, 1500),
buttons: Array.from(document.querySelectorAll('button')).map(b => b.innerText.trim()).filter(Boolean),
cards: Array.from(document.querySelectorAll('.card, .asset-card, .grid-item, tr')).map(c => c.innerText.slice(0, 100)),
projectSelector: document.querySelector('select')?.outerHTML
};
});
console.log('Library inspection:', JSON.stringify(info, null, 2));
// Check Applications page
await page.evaluate(() => {
const items = Array.from(document.querySelectorAll('.nav-item'));
const target = items.find(i => i.innerText.trim().startsWith('Applications'));
if (target) target.click();
});
await page.waitForTimeout(3000);
const appsInfo = await page.evaluate(() => {
return {
text: document.body.innerText.slice(0, 2000),
links: Array.from(document.querySelectorAll('a, button')).map(el => ({ text: el.innerText.trim(), href: el.getAttribute('href'), onclick: el.getAttribute('onclick') })).filter(e => e.text)
};
});
console.log('\nApplications inspection:', JSON.stringify(appsInfo, null, 2));
await browser.close();
})();