-
-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Description
This code causes on error on Invidious which makes it impossible to start a segment.
Lines 2066 to 2079 in 8eb7c0c
| function getRealCurrentTime(): number { | |
| // Used to check if replay button | |
| const playButtonSVGData = document.querySelector(".ytp-play-button")?.querySelector(".ytp-svg-fill")?.getAttribute("d"); | |
| const playButtonSVGDataNew = document.querySelector(".ytp-play-button")?.querySelector("path")?.getAttribute("d"); | |
| const 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"; | |
| const replaceSVGDataNew = "M11.29 2.92C14.85 1.33 18.87 1.06 22"; | |
| if (playButtonSVGData === replaceSVGData || playButtonSVGDataNew.startsWith(replaceSVGDataNew)) { | |
| // At the end of the video | |
| return getVideoDuration(); | |
| } else { | |
| return getCurrentTime(); | |
| } | |
| } |
Obviously these selectors don't work on Invidious. Not sure if the problem that is being worked around here (getCurrentTime wrong when at end-of-video) even exists on Invidious, but in any case the following patch works to avoid the exception:
diff --git a/src/content.ts b/src/content.ts
index cc2edbc0..9a70c4d7 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -2070,7 +2070,7 @@ function getRealCurrentTime(): number {
const 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";
const replaceSVGDataNew = "M11.29 2.92C14.85 1.33 18.87 1.06 22";
- if (playButtonSVGData === replaceSVGData || playButtonSVGDataNew.startsWith(replaceSVGDataNew)) {
+ if (playButtonSVGData === replaceSVGData || (playButtonSVGDataNew !== undefined && playButtonSVGDataNew.startsWith(replaceSVGDataNew))) {
// At the end of the video
return getVideoDuration();
} else {Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels