Fix mark-watched button crash on channel videos tab#251
Merged
Conversation
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>
Adds a channel-videos.html fixture mirroring the real YouTube channel page DOM structure and 23 integration tests covering: video detection, URL/ID extraction, SubscriptionVideo construction, addButton() placement (verifying it doesn't crash and inserts into #meta, not above thumbnail), YouTube watched detection, and hide logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a DOM insertion crash that prevented “mark watched” buttons from appearing on YouTube channel Videos tabs (issue #247) by making the old-layout insertion logic resilient to deeply nested #video-title structures.
Changes:
- Add a defensive guard in
SubscriptionVideo.addButton()to avoid callinginsertBefore()with a non-child reference node; fall back to inserting into the#metaregion on channel layouts. - Add an integration test suite covering channel “Videos” tab DOM structure, video extraction, and button placement behavior.
- Add a new HTML fixture that mirrors the channel “Videos” tab markup hierarchy.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| videos/SubscriptionsVideo.js | Prevents insertBefore crash by verifying the reference node is a direct child; adds channel-layout fallback insertion into #meta. |
| tests/integration/channel-page.test.js | New integration tests validating channel-page video detection/extraction and ensuring addButton() doesn’t throw and places the button in #meta. |
| tests/fixtures/channel-videos.html | New fixture representing the nested channel “Videos” tab DOM needed to reproduce/regress-test #247. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Node.insertBefore: Child to insert before is not a child of this nodeerror#video-title's parent is deeply nested (#dismissible > #details > #meta > h3 > a), not a direct child of the button container —insertBeforerequires a direct child as reference node#metaarea for channel page layoutsTest plan
Hide watched on homeenabled) — verify no regressioninsertBeforeerrors🤖 Generated with Claude Code