From dcd004dabbed3a35cb4f59e94712f358528ead87 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Thu, 21 May 2026 11:43:53 -0500 Subject: check if tags exist before trying to populate them and remove new tags div if no tags exist --- static/index.js | 7 +++++-- templates/watch.html | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/static/index.js b/static/index.js index c753e3f..275e68b 100644 --- a/static/index.js +++ b/static/index.js @@ -2,6 +2,7 @@ const titleBar = document.getElementById("title") const buttonDetails = document.getElementById("toggle-details") const divDetails = document.getElementById("details") +const divTags = document.getElementById("details-tags") const buttonComments = document.getElementById("toggle-comments") const divComments = document.getElementById("comments") const commentTemplate = document.getElementById("template-comment") @@ -108,14 +109,16 @@ async function toggleDetails() { if (detailsLoaded) return toggleVis(divDetails) - // data const data = await getApiReq(`/details?id=${player.playerInfo.videoData.video_id}`) // pop const fieldElements = fillFields(data, divDetails) fieldElements.author.href = `https://www.youtube.com/channel/${data.channel}` - fieldElements.tags.textContent = data.tags.join(", ") + if (data.tags) + fieldElements.tags.textContent = data.tags.join(", ") + else + divTags.remove() // done detailsLoaded = true diff --git a/templates/watch.html b/templates/watch.html index 9849bba..2842547 100644 --- a/templates/watch.html +++ b/templates/watch.html @@ -20,8 +20,10 @@ @
Views => 👍 => Comments

No description has been added to this video.
-

Tags:

-
+
+

Tags:

+
+