Something went wrong. Try again.
this post sux
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667/* BiDi probe #2 — determine whether bsky.app calls window.fetch dynamically. */const ws = new WebSocket("ws://localhost:9222/session");let seq = 0;const pending = new Map();const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
function send(method, params = {}, sessionId = null, timeoutMs = 20000) { const id = ++seq; const msg = { id, method, params }; if (sessionId) msg.sessionId = sessionId; ws.send(JSON.stringify(msg)); return new Promise((resolve, reject) => { const t = setTimeout(() => { pending.delete(id); reject(new Error("timeout " + method)); }, timeoutMs); pending.set(id, { resolve, reject, t }); });}await new Promise((res, rej) => { ws.onopen = res; ws.onerror = () => rej(new Error("no ws")); });ws.onmessage = (ev) => { const m = JSON.parse(ev.data); if (m.id && pending.has(m.id)) { const p = pending.get(m.id); pending.delete(m.id); clearTimeout(p.t); m.type === "success" ? p.resolve(m.result) : p.reject(new Error(m.error.message)); }};
const { sessionId } = await send("session.new", { capabilities: {} });const tree = await send("browsingContext.getTree", {}, sessionId);const ctx = tree.contexts.find((c) => (c.url || "").includes("bsky.app"));if (!ctx) { console.error("no bsky tab"); process.exit(1); }
async function evalStr(expression) { const r = await send("script.evaluate", { expression, target: { context: ctx.context }, awaitPromise: true, resultOwnership: "none" }, sessionId); if (r.result && "value" in r.result) return String(r.result.value); return JSON.stringify(r.result);}async function evalIn(expression) { try { return await evalStr(`JSON.stringify((() => { return ${expression}; })())`); } catch (e) { return "EVAL-ERROR: " + e.message; }}
const fetchSrc = await evalStr(`window.fetch.toString().slice(0, 400)`);console.log("=== window.fetch source ===");console.log(fetchSrc);
console.log("arm:", await evalStr(`(() => { window.__fp = 0; window.__xhr = 0; const of = window.fetch; window.fetch = function (...a) { window.__fp++; return of.apply(this, a); }; const ox = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (...a) { window.__xhr++; return ox.apply(this, a); }; return "armed";})()`));
// force the app to fetch more feedconsole.log("scroll:", await evalStr(`window.scrollTo(0, document.body.scrollHeight); "ok"`));await sleep(7000);console.log("counters@bottom:", await evalIn(`({ fp: window.__fp, xhr: window.__xhr, seen: (window.__suxDiag || {}).seen }))`));console.log("scroll-up:", await evalStr(`window.scrollTo(0, 0); "ok"`));await sleep(4000);console.log("counters@top:", await evalIn(`({ fp: window.__fp, xhr: window.__xhr, seen: (window.__suxDiag || {}).seen })`));try { await send("session.end", {}, sessionId, 5000); } catch {}ws.close();process.exit(0);