From ecd91563d5de43a564bf0508f6913472a08f2b54 Mon Sep 17 00:00:00 2001 From: Bauke Date: Thu, 6 Jul 2023 20:26:08 +0200 Subject: [PATCH] Fix topic votes not being hidden on topic pages. --- source/content-scripts/features/hide-votes.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/content-scripts/features/hide-votes.ts b/source/content-scripts/features/hide-votes.ts index e96d380..70965cf 100644 --- a/source/content-scripts/features/hide-votes.ts +++ b/source/content-scripts/features/hide-votes.ts @@ -100,9 +100,15 @@ function hideCommentVotes(data: HideVotesData, currentUser: string): number { */ function hideTopicVotes(data: HideVotesData, currentUser: string): number { let count = 0; - for (const topic of querySelectorAll(".topic")) { - const postedBySelf = topic.dataset.topicPostedBy === currentUser; + for (const topic of querySelectorAll(".topic", ".topic-full")) { + let topicAuthor = topic.dataset.topicPostedBy; + if (topic.classList.contains("topic-full")) { + topicAuthor = + document.querySelector(".topic-full-byline .link-user")?.textContent ?? + undefined; + } + const postedBySelf = topicAuthor === currentUser; let vote: Element | undefined; // Select the vote number from the topic if we want to hide other's topics