Skip to content

Commit 702cd94

Browse files
OsaSoftclaude
andcommitted
Fix mark-watched button crash on channel videos tab (#247)
On channel pages, #video-title's parent element is deeply nested inside #dismissible > #details > #meta > h3 > a, not a direct child of the button container. This caused insertBefore to throw "Child to insert before is not a child of this node". Now checks if the reference node is a direct child first, and falls back to inserting into #meta area. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cd2e27c commit 702cd94

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

videos/SubscriptionsVideo.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,18 @@ class SubscriptionVideo extends Video {
7979
}
8080
} else {
8181
// Old layout: insert before title area
82-
buttonContainer.insertBefore(container, buttonContainer.querySelector("#video-title")?.parentElement || buttonContainer.firstChild);
82+
let refNode = buttonContainer.querySelector("#video-title")?.parentElement;
83+
if (refNode?.parentElement !== buttonContainer) {
84+
// Channel page layout: #video-title is deeply nested, insert into #meta area
85+
let metaDiv = buttonContainer.querySelector("#meta");
86+
if (metaDiv) {
87+
metaDiv.appendChild(container);
88+
} else {
89+
buttonContainer.appendChild(container);
90+
}
91+
} else {
92+
buttonContainer.insertBefore(container, refNode || buttonContainer.firstChild);
93+
}
8394
}
8495
}
8596
}

0 commit comments

Comments
 (0)