From 928c075416ee1ca9b710c9396be97a4a1117a753 Mon Sep 17 00:00:00 2001 From: Manual Date: Fri, 26 Mar 2021 12:00:47 +0200 Subject: [PATCH 1/2] fix exception when on youtube.com/tv --- src/content.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content.ts b/src/content.ts index ba1bd757..6bbbc46e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1530,6 +1530,7 @@ function getSegmentsMessage(sponsorTimes: SponsorTime[]): string { function addHotkeyListener(): boolean { let videoRoot = document.getElementById("movie_player") as HTMLDivElement; if (onInvidious) videoRoot = (document.getElementById("player-container") ?? document.getElementById("player")) as HTMLDivElement; + if (video.baseURI.startsWith("https://www.youtube.com/tv#/")) videoRoot = document.querySelector("ytlr-watch-page") as HTMLDivElement; if (!videoRootsWithEventListeners.includes(videoRoot)) { videoRoot.addEventListener("keydown", hotkeyListener); From 719010db976334cdefad436f36e6fc651895c901 Mon Sep 17 00:00:00 2001 From: Manual Date: Sat, 27 Mar 2021 00:08:02 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Don=E2=80=99t=20throw=20an=20exception=20if?= =?UTF-8?q?=20there=E2=80=99s=20no=20videoRoot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested change by @ajayyy Co-authored-by: Ajay Ramachandran --- src/content.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 6bbbc46e..33842dd3 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1532,7 +1532,7 @@ function addHotkeyListener(): boolean { if (onInvidious) videoRoot = (document.getElementById("player-container") ?? document.getElementById("player")) as HTMLDivElement; if (video.baseURI.startsWith("https://www.youtube.com/tv#/")) videoRoot = document.querySelector("ytlr-watch-page") as HTMLDivElement; - if (!videoRootsWithEventListeners.includes(videoRoot)) { + if (videoRoot && !videoRootsWithEventListeners.includes(videoRoot)) { videoRoot.addEventListener("keydown", hotkeyListener); videoRootsWithEventListeners.push(videoRoot); return true;