fix: pierce new-reddit (shreddit) shadow DOM when collecting comment text (closes task/handle-shreddit-shadow-dom)

Source: task/handle-shreddit-shadow-dom (plan/steward-linker-design) — the TreeWalker only walked light DOM, so new-reddit comment bodies inside shadow roots were missed.

- collectTextNodes now walks the comment-tree root's light DOM AND recursively descends into the open shadow roots of elements within that subtree, so comment text is reached whether reddit slots it (light DOM) or encapsulates it (shadow DOM).
- Scoped to getRoot()'s comment tree (never the whole document's shadow roots); bounded by a depth cap; a no-op on old reddit (no shadow roots).
- Slotted light-DOM nodes are not double-collected (a shadow walker sees the shadow tree's own nodes, not a <slot>'s assigned light nodes); a Set de-dupes by node identity belt-and-braces.
- All existing guards preserved (inSkippable / rsl-link skip). README + AGENTS document the support.
- Limitation: CLOSED shadow roots are unreachable from a content script and stay unlinked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
paul
2026-06-23 14:28:31 +00:00
co-authored by Claude Opus 4.8
parent 5a3abf6c89
commit 071cc3f85a
3 changed files with 50 additions and 4 deletions
+5
View File
@@ -180,6 +180,11 @@ let the content script reach it).
name links to a Google search for "<name> bandcamp" (which surfaces the Bandcamp page).
- **Without Spotify creds or the LLM, nothing links** — at least one gate must be
configured.
- **New reddit (shreddit) shadow DOM** — the comment-text scan pierces the **open**
shadow roots of the `shreddit-*` web components within the comment tree, so it links
comment bodies whether reddit slots them into light DOM or encapsulates them in a
shadow root. **Closed** shadow roots are unreachable from a content script and stay
unlinked (a browser limitation, not a setting).
- The optional LLM adds a little latency on the **first** call (ollama warms the
model), then is fast.
- The resolver caches results in memory; it resets when you restart it.