Something went wrong. Try again.
this post sux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102/* BiDi probe — validate the action-bar item rule against the real feed DOM. */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)) return; 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" }, sessionId); await send("browsingContext.navigate", { context: ctx.context, url: "https://bsky.app/" }, sessionId); await sleep(12000);}async function val(expression) { try { const r = await send("script.evaluate", { expression: "JSON.stringify(String(" + expression + "))", target: { context: ctx.context }, awaitPromise: true, resultOwnership: "none" }, sessionId); return r && r.result && "value" in r.result ? String(r.result.value) : "NO-RESULT"; } catch (e) { return "ERR:" + e.message; }}
console.log(await val(`(() => { const ACTION = '[aria-label^="Reply"], [aria-label^="Like"], [aria-label^="Repost"]'; const norm = (href) => { if (!href) return null; const h = href.replace(/^https?:\\/\\/[^/]+/i, "").split("?")[0].split("#")[0]; return h.match(/^\\/profile\\/[^/]+\\/post\\/[^/]+\\/?$/) ? h : null; }; const anchorKids = (el) => el && el.parentElement ? Array.from(el.parentElement.children).filter((c) => c.querySelector('a[href*="/post/"]')).length : -1; const oldRule = (anchor) => { let node = anchor.parentElement; for (let d = 0; node && node !== document.body && d < 12; d++) { const parent = node.parentElement; if (parent) { const sib = parent.querySelectorAll('a[href*="/post/"]'); for (let i = 0; i < sib.length; i++) if (!node.contains(sib[i])) return node; } node = parent; } return anchor.parentElement; }; const bar2 = (anchor) => { let node = anchor.parentElement; for (let d = 0; node && node !== document.body && d < 14; d++) { const parent = node.parentElement; if (parent) { let kids = 0; for (const ch of parent.children) if (ch.querySelector(ACTION)) kids++; if (kids >= 2) return node; } node = parent; } return null; }; const simple = (anchor) => { let node = anchor.parentElement; for (let d = 0; node && node !== document.body && d < 14; d++) { if (node.querySelector(ACTION)) return node; node = node.parentElement; } return null; }; const anchors = Array.from(document.querySelectorAll('a[href*="/post/"]')).filter((a) => norm(a.getAttribute("href"))); const seen = new Set(); const out = []; for (const a of anchors) { const o = oldRule(a), b = bar2(a), s = simple(a); if (!b || seen.has(b)) continue; seen.add(b); out.push({ sameOB: o === b, sameOS: o === s, sameBS: b === s, bar2AnchorKids: anchorKids(b), oldAnchorKids: anchorKids(o), bar2Anchors: b.querySelectorAll('a[href*="/post/"]').length, oldAnchors: o.querySelectorAll('a[href*="/post/"]').length, }); if (out.length >= 5) break; } return JSON.stringify(out);})()`));try { await send("session.end", {}, sessionId, 5000); } catch {}ws.close();process.exit(0);