fix: scope getRoot to the comment tree so the shadow walk doesn't collect reddit chrome (closes task/getroot-comment-tree-scope)

Source: task/getroot-comment-tree-scope (plan/steward-linker-design) — getRoot's union querySelector resolved to <main> on new reddit, so the shadow-piercing walk over-collected reddit chrome.

- getRoot now tries shreddit-comment-tree, then .commentarea, then main/body sequentially (narrow-first) instead of one union querySelector, so the comment tree wins when present.
- collectInto takes an allowShadow flag: a narrow comment root pierces every open shadow host; a broad fallback root descends only into comment-component hosts (tagName SHREDDIT-COMMENT*), so chrome shadow roots (nav/sidebar/composer) are never walked.
- README + AGENTS shadow-DOM notes updated to describe the two-layer scoping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
paul
2026-06-23 16:38:11 +00:00
co-authored by Claude Opus 4.8
parent a14f566e53
commit 8ac0666a71
3 changed files with 59 additions and 26 deletions
+8 -5
View File
@@ -180,11 +180,14 @@ 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).
- **New reddit (shreddit) shadow DOM** — the scan roots at the comment tree
(`shreddit-comment-tree`, falling back to old reddit's `.commentarea`, then `main`/`body`)
and pierces the **open** shadow roots of the `shreddit-*` web components within it, so it
links comment bodies whether reddit slots them into light DOM or encapsulates them in a
shadow root. On a broad fallback root (no comment tree found) only comment-component shadow
roots are descended, so reddit's chrome (nav, sidebar, composer) is never collected.
**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.