stop sponsorblock on playback preview videos #104
Merged
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.
Symptom
i. You'll also see the notification for it as well
ii. In console, you'll see the logs for the previous video ID, confirming that its executing previous video's skip segments
Cause
When a video is loaded, we initialize SponsorBlock. However, if you go back to YouTube homepage, and hover on a video tile, it starts to play a video.
Since SponsorBlock is already initialized, the listeners for video element are still listening to video's
play
,pause
,timeupdate
anddurationchange
listener - technically, the video element on a/watch
page is the same video element on home page for preview playback.This causes it to execute back the
scheduleSkipHandler
.Ideal Solution
IDEALLY, we would want to load SponsorBlock for the video being played in the preview on homepage.
However, there is no way (or should I say an easy way) to know the video ID for the preview playback video.
Proposed Solution
When the page is changed, and it is not the video page, uninitialize SponsorBlock.