Check if name node is present before using it

This commit is contained in:
sto
2025-11-09 11:05:48 +01:00
parent 5d1390c480
commit 8269e75020

View File

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