diff --git a/scripts/content.js b/scripts/content.js index c328eb9..8241128 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -51,6 +51,9 @@ function checkNewMessages() { for (let messageNode of messageElements) { const el = messageNode.firstChild.firstChild.firstChild.firstChild; if (seenMessages.has(el)) continue; + const rootNode = messageNode.parentNode.parentNode; + if (!rootNode.firstChild.firstChild) continue; + const name = rootNode.firstChild.firstChild.innerHTML; newElements = true; seenMessages.add(el); let completionTime = Math.floor((Date.now() - startTime) / 1000); @@ -58,8 +61,6 @@ function checkNewMessages() { // If awaiting times are available, use them first (i.e. the messages section just got opened). if (awaitingTimes.length) completionTime = awaitingTimes.shift(); - const rootNode = messageNode.parentNode.parentNode; - const name = rootNode.firstChild.firstChild.innerHTML; const dTime = displayTime(completionTime); if (startTime > 0) { const text = el.innerHTML;