From 8e762c592ab16574ea4953725643d9c34d107978 Mon Sep 17 00:00:00 2001 From: bp Date: Fri, 4 Nov 2022 16:13:43 +0100 Subject: [PATCH] views/tweet: add .author-$user, .retweet-$user to classlist for adblock Allow users to control what content they see or don't in their timelines by exposing author and retweeter information via dedicated CSS classes. Using adblock extensions is at least a little of a cop out, especially considered the changes to extensions that Chrome will soon force on extensions, but it's also the simplest change that will do the trick... at least on desktop. Server-side blocking would require an account system to exist, whereas javascript-side blocking would require javascript to be enabled, something that nitter doesn't give for granted (see also: video playback). Javascript-side blocking would also benefit some kind of change very much like the one I'm making here (the alternative being scraping the DOM this piece of code is generating). --- src/views/tweet.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/tweet.nim b/src/views/tweet.nim index daad61a..dbd41e0 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -295,6 +295,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0; divClass = "thread-last " & class if not tweet.available: + divClass &= " author-" & tweet.user.username return buildHtml(tdiv(class=divClass & "unavailable timeline-item")): tdiv(class="unavailable-box"): if tweet.tombstone.len > 0: @@ -313,6 +314,9 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0; if tweet.retweet.isSome: tweet = tweet.retweet.get retweet = fullTweet.user.fullname + divClass &= " retweet-" & retweet + + divClass &= " author-" & tweet.user.fullname buildHtml(tdiv(class=("timeline-item " & divClass))): if not mainTweet: