← back to Hormuzy
clone/recon.js
59 lines
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');
const OUT = path.join(__dirname, 'recon');
fs.mkdirSync(OUT, { recursive: true });
(async () => {
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox', '--use-gl=swiftshader', '--disable-dev-shm-usage'] });
// Desktop
const ctxD = await browser.newContext({
viewport: { width: 1440, height: 900 },
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
recordVideo: { dir: OUT, size: { width: 1440, height: 900 } }
});
const pD = await ctxD.newPage();
await pD.goto('https://www.hormuzy.com/', { waitUntil: 'networkidle', timeout: 45000 }).catch(() => {});
await pD.waitForTimeout(4000);
await pD.screenshot({ path: path.join(OUT, 'desktop-00-splash.png'), fullPage: false });
await pD.waitForTimeout(2000);
await pD.screenshot({ path: path.join(OUT, 'desktop-01-later.png'), fullPage: false });
// Try to dump rendered DOM text for signage
const copy = await pD.evaluate(() => {
const getText = (el) => (el ? (el.innerText || el.textContent || '').trim() : '');
return {
title: document.title,
h1s: Array.from(document.querySelectorAll('h1,h2,h3,button,a,.title,[class*="title"],[class*="Title"]')).map(el => getText(el)).filter(Boolean).slice(0, 40),
body: getText(document.body).slice(0, 3000),
bg: getComputedStyle(document.body).backgroundColor,
fontFamily: getComputedStyle(document.body).fontFamily
};
});
fs.writeFileSync(path.join(OUT, 'desktop-copy.json'), JSON.stringify(copy, null, 2));
await pD.waitForTimeout(8000);
await pD.screenshot({ path: path.join(OUT, 'desktop-02-gameplay.png'), fullPage: false });
await ctxD.close();
// Mobile
const ctxM = await browser.newContext({
viewport: { width: 390, height: 844 },
deviceScaleFactor: 3,
isMobile: true,
hasTouch: true,
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
recordVideo: { dir: OUT, size: { width: 390, height: 844 } }
});
const pM = await ctxM.newPage();
await pM.goto('https://www.hormuzy.com/', { waitUntil: 'networkidle', timeout: 45000 }).catch(() => {});
await pM.waitForTimeout(4000);
await pM.screenshot({ path: path.join(OUT, 'mobile-00-splash.png'), fullPage: false });
await pM.waitForTimeout(6000);
await pM.screenshot({ path: path.join(OUT, 'mobile-01-gameplay.png'), fullPage: false });
await ctxM.close();
await browser.close();
console.log('DONE');
})().catch(e => { console.error('ERR', e); process.exit(1); });