File size: 1,831 Bytes
28e3615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import puppeteer from "puppeteer-core";
const URL_ = process.argv[2] || "https://devseis-caveat.static.hf.space/";
const S = "/Users/umer/Documents/hf/tools/browser-tests/out";
const b = await puppeteer.launch({ executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", headless: true, userDataDir: S + "/prof_net", protocolTimeout: 180000 });
const p = await b.newPage(); await p.setCacheEnabled(false);
const reqs = new Map(); const errs = [];
p.on("pageerror", (e) => errs.push(e.message));
p.on("response", async (r) => { const u = r.url(); const host = new URL(u).host; if (!u.startsWith("data:")) { let len = Number(r.headers()["content-length"] || 0); reqs.set(u, { host, status: r.status(), len }); } });
await p.setRequestInterception(true);
p.on("request", (r) => /clarity\.ms/.test(r.url()) ? r.abort() : r.continue());
await p.goto(URL_, { waitUntil: "domcontentloaded" });
await p.waitForFunction(() => !document.getElementById("runBtn").disabled && document.getElementById("runBtn").textContent === "Check", { timeout: 150000 });
if (await p.evaluate(() => !document.getElementById("consent").hidden)) await p.click("#consentDecline");
await p.click('.chip[data-ex="2"]'); await p.click("#runBtn");
await p.waitForFunction(() => !document.getElementById("p1result").hidden, { timeout: 60000 });
const p1 = await p.$eval("#p1pill", (e) => e.textContent);
const hosts = {};
for (const [u, v] of reqs) { (hosts[v.host] ||= []).push(`${v.status} ${(v.len / 1e6).toFixed(2)}MB ${u.replace(/^https?:\/\/[^/]+/, "")}`); }
for (const [h, list] of Object.entries(hosts)) { console.log(`== ${h} (${list.length})`); if (h !== new URL(URL_).host) list.forEach((l) => console.log("   " + l)); }
console.log("trained model answer:", p1, "| errors:", errs.length ? errs.join(" | ") : "none");
await b.close();