From 1832a12d29e3f42060a3d9d6f22adc8986c246cd Mon Sep 17 00:00:00 2001 From: hibutwhy <112614297+hibutwhy@users.noreply.github.com> Date: Sun, 23 Aug 2026 22:10:52 -0700 Subject: [PATCH] Make hashtags in video titles clickable --- src/invidious/helpers/utils.cr | 12 ++++++++++++ src/invidious/views/watch.ecr | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 7a262f849..f0efa245f 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -386,6 +386,18 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String) return text end +def linkify_hashtags(title : String) : String + String.build do |str| + pos = 0 + title.scan(/#([a-zA-Z0-9_]+)/) do |match| + str << title[pos...match.begin(0)] + str << %(#{match[0]}) + pos = match.end(0) + end + str << title[pos..] + end +end + def encrypt_ecb_without_salt(data, key) cipher = OpenSSL::Cipher.new("aes-128-ecb") cipher.encrypt diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 3dc19c9e2..266065fbc 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -93,7 +93,11 @@ we're going to need to do it here in order to allow for translations.

- <%= title %> + <% if video.title.matches?(/#\w/) %> + <%= linkify_hashtags(title) %> + <% else %> + <%= title %> + <% end %> <% if params.listen %> " id="link-iv-listen" data-base-url="/watch?<%= env.params.query %>&listen=0" href="/watch?<%= env.params.query %>&listen=0">