Don’t throw an exception if there’s no videoRoot

Suggested change by @ajayyy

Co-authored-by: Ajay Ramachandran <dev@ajay.app>
This commit is contained in:
Manual
2021-03-27 00:08:02 +02:00
committed by GitHub
parent 928c075416
commit 719010db97

View File

@@ -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;