From c10342e8350aeaff080995e1cb3c8c92706b5fbb Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 20:54:52 +0200 Subject: [PATCH] fix error in console --- files/templates/comments.html | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/files/templates/comments.html b/files/templates/comments.html index 6ca262425..9939e7f78 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -895,18 +895,21 @@ const detectionDiv = document.querySelector('#detection'); const isAutoDark = getComputedStyle(detectionDiv).backgroundColor != 'rgb(255, 255, 255)'; if (!isAutoDark) { - const element = document.getElementsByClassName('comment-section')[0]; - let color = getComputedStyle(element).getPropertyValue('background-color'); - color = 'rgba' + color.slice(3,-1) + ', 0.1)' + let element = document.getElementsByClassName('comment-section') + if (element) { + element = element[0]; + let color = getComputedStyle(element).getPropertyValue('background-color'); + color = 'rgba' + color.slice(3,-1) + ', 0.1)' - const markTemplate = (name) => { - return `${name}`; - }; - const base64Mark = btoa(markTemplate("{{v.id}}")); - - var style = document.createElement('style'); - style.innerHTML = `.actual-post:not(.deleted):not(.banned),.comment-section>.comment{background-image:url("data:image/svg+xml;base64,${base64Mark}")}`; - document.getElementsByTagName('head')[0].appendChild(style); + const markTemplate = (name) => { + return `${name}`; + }; + const base64Mark = btoa(markTemplate("{{v.id}}")); + + var style = document.createElement('style'); + style.innerHTML = `.actual-post:not(.deleted):not(.banned),.comment-section>.comment{background-image:url("data:image/svg+xml;base64,${base64Mark}")}`; + document.getElementsByTagName('head')[0].appendChild(style); + } } {% endif %}