Something went wrong. Try again.
this post sux
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071/* BiDi probe #4 — manual feed fetch through window.fetch; XHR counters; SW check. */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(JSON.stringify(m.error))); }};
const { sessionId } = await send("session.new", { capabilities: {} });const tree = await send("browsingContext.getTree", {}, sessionId);let ctx = tree.contexts.find((c) => (c.url || "").includes("bsky.app"));if (!ctx) { ctx = await send("browsingContext.create", { type: "tab", url: "https://bsky.app/" }, sessionId); console.log("created new bsky tab:", ctx.context); await sleep(10000);}
async function val(expression) { try { const r = await send("script.evaluate", { expression, target: { context: ctx.context }, awaitPromise: true, resultOwnership: "none" }, sessionId); if (!r || !r.result) return "NO-RESULT:" + JSON.stringify(r); return "value" in r.result ? String(r.result.value) : JSON.stringify(r.result); } catch (e) { return "ERR:" + e.message; }}
console.log("transport counters:", await val(`JSON.stringify({fp: window.__fp|0, xhr: window.__xhr|0})`));console.log("service workers:", await val(`navigator.serviceWorker ? navigator.serviceWorker.getRegistrations().then(rs => rs.map(r=>r.scope).join(",") || "none") : "no-sw-api"`));console.log("diag before:", await val(`window.__suxDiag ? JSON.stringify(Object.keys(window.__suxDiag)) : "none"`));
console.log("manual getTimeline via window.fetch…");await val(`window.__manualResult = "pending"; window.fetch("https://bsky.app/xrpc/app.bsky.feed.getTimeline?limit=1", { credentials: "include" }) .then(r => r.status === 200 ? r.json() : { httpStatus: r.status }) .then(j => { window.__manualResult = j.feed ? "feed:" + j.feed.length : "keys:" + Object.keys(j).join(","); }) .catch(e => { window.__manualResult = "err:" + e.message; }); "sent"`);await sleep(4000);console.log("manual result:", await val(`window.__manualResult`));console.log("diag.seen after manual:", await val(`window.__suxDiag && window.__suxDiag.seen`));console.log("diag.scans:", await val(`window.__suxDiag && window.__suxDiag.scans`));
console.log("scroll…");await val(`window.scrollTo(0, document.body.scrollHeight); "ok"`);await sleep(5000);console.log("transport counters:", await val(`JSON.stringify({fp: window.__fp|0, xhr: window.__xhr|0})`));console.log("diag.scans after scroll:", await val(`window.__suxDiag && window.__suxDiag.scans`));console.log("diag.seen after scroll:", await val(`window.__suxDiag && window.__suxDiag.seen`));
try { await send("session.end", {}, sessionId, 5000); } catch {}ws.close();process.exit(0);