diff --git a/src/content/ui/lifecycle.ts b/src/content/ui/lifecycle.ts index c5b7b57..f34b49d 100644 --- a/src/content/ui/lifecycle.ts +++ b/src/content/ui/lifecycle.ts @@ -7,10 +7,12 @@ const CONTAINER_ID = "ytpf-playlist-table"; let currentHandle: PlaylistTableHandle | null = null; function findAnchor(): { parent: Element; before: Element | null } | null { - // Primary: before ytd-playlist-video-list-renderer (sibling) - const videoList = document.querySelector("ytd-playlist-video-list-renderer"); - if (videoList?.parentElement) { - return { parent: videoList.parentElement, before: videoList }; + // Primary: top of ytd-item-section-renderer (before any header/content) + const itemSection = document.querySelector( + "ytd-section-list-renderer ytd-item-section-renderer", + ); + if (itemSection) { + return { parent: itemSection, before: itemSection.firstElementChild }; } // Fallback: end of ytd-section-list-renderer > #contents