From a45bd4c5c7f6c0ac3d4ae8356588f3894cce3f52 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 15 Jan 2022 18:28:53 -0500 Subject: [PATCH] Fix potential null issue --- src/utils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index f7bf748c..cbbf03a3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -343,13 +343,15 @@ export default class Utils { //for embeds const player = document.getElementById("player"); referenceNode = player.firstChild as HTMLElement; - let index = 1; + if (referenceNode) { + let index = 1; - //find the child that is the video player (sometimes it is not the first) - while (index < player.children.length && (!referenceNode.classList.contains("html5-video-player") || !referenceNode.classList.contains("ytp-embed"))) { - referenceNode = player.children[index] as HTMLElement; + //find the child that is the video player (sometimes it is not the first) + while (index < player.children.length && (!referenceNode.classList.contains("html5-video-player") || !referenceNode.classList.contains("ytp-embed"))) { + referenceNode = player.children[index] as HTMLElement; - index++; + index++; + } } }