Something went wrong. Try again.
this post sux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566/* BiDi probe #9 — watch verdicts flow back: diag fields, hidden counts, and the sidebar's own stats line if its context is reachable. */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 = 25000) { 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: {} });
async function val(context, expression) { try { const r = await send("script.evaluate", { expression, target: { context }, awaitPromise: true, resultOwnership: "none" }, sessionId); if (!r || !r.result) return "NO-RESULT"; return "value" in r.result ? String(r.result.value) : JSON.stringify(r.result); } catch (e) { return "ERR:" + e.message; }}
const tree1 = await send("browsingContext.getTree", {}, sessionId);console.log("contexts:");tree1.contexts.forEach((c) => console.log(" ", c.context, c.url || ""));const bsky = tree1.contexts.find((c) => (c.url || "").includes("bsky.app"));const sidebar = tree1.contexts.find((c) => (c.url || "").includes("moz-extension://"));
async function diagSnapshot(label) { const fields = ["seen", "domExtracted", "items", "hidden", "unmatchedAnchors", "scans", "settingsActive"]; const parts = []; for (const f of fields) { parts.push(f + "=" + (await val(bsky.context, "window.__suxDiag ? String(window.__suxDiag." + f + ") : 'NONE'"))); } console.log(label, "→", parts.join(" "));}
await diagSnapshot("t+0s");await sleep(45000);await diagSnapshot("t+45s");if (sidebar) { console.log("sidebar status line:", await val(sidebar.context, "(document.getElementById('status')||{textContent:'n/a'}).textContent")); console.log("sidebar diag line: ", await val(sidebar.context, "(document.getElementById('diag')||{textContent:'n/a'}).textContent")); console.log("sidebar lastError: ", await val(sidebar.context, "(document.getElementById('lastError')||{textContent:'n/a'}).textContent")); console.log("sidebar perm banner:", await val(sidebar.context, "(document.getElementById('permBanner')||{hidden:'n/a'}).hidden"));} else { console.log("sidebar context not visible to BiDi");}try { await send("session.end", {}, sessionId, 5000); } catch {}ws.close();process.exit(0);