File size: 1,669 Bytes
b9c1c87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { chromium } = require('playwright-core');
(async () => {
  const b = 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 b.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(12000);

  for (let round = 0; round < 25; round++) {
    const clicked = await page.evaluate(() => {
      const norm = s => (s || '').trim().toUpperCase();
      const btns = [...document.querySelectorAll('button, [role="button"]')]
        .filter(e => e.offsetParent !== null);
      const wanted = ['LAUNCH', 'CONTINUE', 'NEXT', 'SKIP', 'ENTER', 'GOT IT', 'DONE', 'CLOSE', 'ACCEPT'];
      for (const w of wanted) {
        const hit = btns.find(x => norm(x.innerText) === w);
        if (hit) { hit.click(); return 'text:' + w; }
      }
      const aria = document.querySelector('button[aria-label="Close"], button[aria-label="close"]');
      if (aria && aria.offsetParent !== null) { aria.click(); return 'aria:close'; }
      return null;
    });
    if (!clicked) break;
    console.log('click', clicked);
    await page.waitForTimeout(3500);
  }
  await page.waitForTimeout(35000);
  await page.screenshot({ path: '/data/shots/shadowbroker_dash.png' });
  const t = (await page.evaluate(() => document.body.innerText)).replace(/\s+/g, ' ');
  console.log('LEN', t.length, '|', t.slice(0, 300));
  await b.close();
})();