helloworld / deploy /scripts /shot3.js
eduzrh's picture
Upload deploy/scripts/shot3.js with huggingface_hub
f9de565 verified
Raw History Blame Contribute Delete
1.47 kB
const { chromium } = require('playwright-core');
(async () => {
const browser = await chromium.launch({
executablePath: '/data/tools/chrome-headless-shell-linux64/chrome-headless-shell',
args: ['--no-sandbox', '--disable-dev-shm-usage', '--use-gl=swiftshader',
'--enable-unsafe-swiftshader'],
});
const ctx = await browser.newContext({ viewport: { width: 1600, height: 1000 } });
const page = await ctx.newPage();
await page.goto('http://127.0.0.1/', { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForTimeout(15000);
const sels = ['button:has-text("CONTINUE")', 'button:has-text("NEXT")',
'button:has-text("SKIP")', 'button:has-text("GET STARTED")',
'button:has-text("ENTER")', 'button:has-text("LAUNCH")', 'button[aria-label="Close"]'];
for (let i = 0; i < 8; i++) {
let clicked = false;
for (const s of sels) {
try {
const el = page.locator(s).first();
if (await el.count() && await el.isVisible()) {
await el.click({ timeout: 4000 }); clicked = true;
await page.waitForTimeout(4000); break;
}
} catch (e) {}
}
if (!clicked) break;
}
await page.waitForTimeout(45000);
await page.screenshot({ path: '/data/shots/shadowbroker_ready.png' });
const t = (await page.evaluate(() => document.body.innerText)).replace(/\s+/g, ' ');
console.log('TEXT:', t.slice(0, 500));
await browser.close();
})();