テーブルのマウント位置の調整

This commit is contained in:
Keisuke Hirata 2026-04-09 03:12:59 +09:00
parent 668574341e
commit 4f401356cd

View File

@ -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