From d1748f1758130dfc510cf66eed4f14ccbee3f534 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 11 May 2020 19:27:26 -0400 Subject: [PATCH] Changed endscreen check to use replay button instead. --- src/content.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/content.ts b/src/content.ts index 42f8dc42..6d234a9a 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1130,13 +1130,16 @@ function getRoughCurrentTime(): number { let htmlCurrentTimeString = document.querySelector(".ytp-time-current").textContent; let htmlDurationString = document.querySelector(".ytp-time-duration").textContent; - // Used to check if endscreen content is visible - let endScreenContent = document.querySelector(".ytp-endscreen-content"); - // Used to check autoplay display - let autoPlayDisplay: HTMLDivElement = document.querySelector(".ytp-upnext"); + if (htmlCurrentTimeString == htmlDurationString) { + // At the end of the video + return video.duration; + } - if (htmlCurrentTimeString == htmlDurationString - || endScreenContent.childElementCount > 0 || autoPlayDisplay.style.display !== "none") { + // Used to check if replay button + let playButtonSVGData = document.querySelector("ytp-play-button")?.querySelector("ytp-svg-fill")?.getAttribute("d"); + let replaceSVGData = "M 18,11 V 7 l -5,5 5,5 v -4 c 3.3,0 6,2.7 6,6 0,3.3 -2.7,6 -6,6 -3.3,0 -6,-2.7 -6,-6 h -2 c 0,4.4 3.6,8 8,8 4.4,0 8,-3.6 8,-8 0,-4.4 -3.6,-8 -8,-8 z"; + + if (playButtonSVGData === replaceSVGData) { // At the end of the video return video.duration; }