File size: 2,752 Bytes
28e3615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import puppeteer from "puppeteer-core";
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_i3", protocolTimeout: 90000 });
const p = await b.newPage(); await p.setCacheEnabled(false);
const errs = []; p.on("pageerror", (e) => errs.push(e.message));
await p.setRequestInterception(true);
p.on("request", (r) => {
  const u = r.url();
  if (u.includes("cdn.jsdelivr.net/npm/@huggingface/transformers")) return r.respond({ status: 200, contentType: "application/javascript", headers: { "Access-Control-Allow-Origin": "*" }, body: "export const env={}; export async function pipeline(){ return async()=>[{label:'high_risk',score:.9}]; }" });
  if (/\.onnx|clarity\.ms|workers\.dev/.test(u)) return r.abort();
  r.continue();
});
for (const [label, vp] of [["phone", { width: 390, height: 844, deviceScaleFactor: 2, isMobile: true, hasTouch: true }], ["desktop", { width: 1280, height: 900, deviceScaleFactor: 1 }]]) {
  await p.setViewport(vp);
  await p.goto("http://localhost:8766/#dates", { waitUntil: "networkidle2" });
  if (await p.$("#consentDecline") && await p.evaluate(() => !document.getElementById("consent").hidden)) await p.click("#consentDecline");
  await new Promise((r) => setTimeout(r, 900));
  const m = await p.evaluate(() => ({
    tab: document.querySelector(".tab-btn[aria-selected=true]").textContent, datesTop: Math.round(document.getElementById("dates").getBoundingClientRect().top),
    items: [...document.querySelectorAll("#datesList li")].map((li) => (li.className || "future") + ":" + li.querySelector(".d").textContent + [...li.querySelectorAll(".tagx")].map((t) => "[" + t.textContent + "]").join("")),
    pageW: document.documentElement.scrollWidth, vw: innerWidth,
    story: !!document.querySelector("#devseisStory .devseis"), dupIds: document.querySelectorAll("#devseisBlock").length,
    links: [...document.querySelectorAll("#devseisBlock a[href^='http']")].map((a) => a.href) }));
  console.log(`${label}: tab=${m.tab} | #dates scrolled into view (top ${m.datesTop}px) | page ${m.pageW}/${m.vw} | Devseis block in Story: ${m.story} | ids: ${m.dupIds}`);
  if (label === "phone") { console.log("  timeline:\n   " + m.items.join("\n   ")); globalThis.links = m.links; }
  await p.evaluate(() => document.querySelector('[data-tab="results"]').click()); await new Promise((r) => setTimeout(r, 300));
  await p.screenshot({ path: `${S}/results_${label}.png`, fullPage: true });
}
console.log("page errors:", errs.length ? errs.join(" | ") : "none"); await b.close();
import fs from "fs"; fs.writeFileSync(S + "/links.txt", globalThis.links.join("\n"));