// A reply's THREAD SHOT: the post it answers, over the reply itself, as one // picture -- `shot-thread.png` beside the post's own `shot.png`, never in its // place (postCapture.ts has the layout; xPostCapture.ts calls this after the // post's own shot, in the same page load). // // An X status page for a reply renders the conversation above the post: its // parent, the parent's parent, up to the root, each an // `article[data-testid="tweet"]`. The thread shot is cut to ONE of them, the // IMMEDIATE parent -- the box from that article's top to the reply's bottom. // Which article that is: the one whose status link is the id the archive // says the reply answers (`replyTo.id`); with no archive word, the article // directly above the reply. An archive id that is not on the page is no // parent at all -- the article above it would be a grandparent (X draws a // deleted or walled parent as a notice, not an article), and a shot that // names the wrong post as the one replied to is worse than none. // // PRIVACY. The parent's author is often a private person replying to a // public one. By default the shot blurs the parent's avatar, display name and // @handle, and every link to their profile in the reply (the "Replying to" // line and any @mention), unless the parent's author is verified or is the // reply's own author (a self-thread). VERIFIED MEANS AN ORGANISATION'S GOLD // CHECK OR A GOVERNMENT'S GREY ONE: X's blue check is X Premium's, bought by // anyone, so a blue-checked private person is blurred like any other (the // proof run's parent was one: a person asking "How's Huck?"); the badge is // recorded either way, and `redact: false` lets a public blue-checked // author through. The blur is a CSS filter set on those // elements in the page before the shot; their boxes are measured after it // and recorded, in the shot's own pixels, in capture.json. A parent whose // name cannot be found to blur gets NO thread shot: the blur is not skipped // to get a picture. // // `redact: false` turns the blur off (an author the operator has judged // public); `redact: true` blurs even a gold- or grey-checked author. // // NOT VERIFIED AGAINST LIVE X beyond the one proof run the CHANGELOG names; // the markers are X's as of 2026-10. import { mkdir, writeFile } from "node:fs/promises"; import path from "node:path"; import type { PageLike } from "./playwrightRuntime"; import { describeCapturedFile, THREAD_SHOT_FILENAME, type RedactedBox, type ThreadCaptureRecord, type ThreadRedactionReason, } from "./postCapture"; import { shootFromViewport, unionBox } from "./viewportShot"; // The post's own article (xPostCapture.ts marks it) and its parent's. export const OWN_SELECTOR = "[data-archilyzer-capture]"; export const PARENT_SELECTOR = "[data-archilyzer-thread-parent]"; const REDACTED_ATTR = "data-archilyzer-redacted"; export const THREAD_SNAPSHOT_MARKER = "__archilyzerThreadSnapshot"; export const MARK_PARENT_MARKER = "__archilyzerMarkParent"; export const REDACT_MARKER = "__archilyzerRedact"; export const REDACTED_BOXES_MARKER = "__archilyzerBlurredBoxes"; // One article of the page as the thread snapshot reads it, in document order. export type ThreadArticle = { // Its status link (the one holding its