Invidious is an alternative front-end to YouTube
show member icon, hide deleted emojis, fix non-custom emojis
ChunkyProgrammer76ad4e802603
diff --git a/locales/en-US.json b/locales/en-US.jsonindex a5c16fd7..5bbf6db6 100644--- a/locales/en-US.json+++ b/locales/en-US.json@@ -405,6 +405,7 @@"YouTube comment permalink": "YouTube comment permalink","permalink": "permalink","`x` marked it with a ❤": "`x` marked it with a ❤",+ "Member": "Member","Audio mode": "Audio mode","Video mode": "Video mode","Playlists": "Playlists",diff --git a/src/invidious/comments.cr b/src/invidious/comments.crindex 5749248e..f1942ceb 100644--- a/src/invidious/comments.cr+++ b/src/invidious/comments.cr@@ -328,11 +328,21 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false)endauthor_name = HTML.escape(child["author"].as_s)+ member_icon = ""if child["verified"]?.try &.as_bool && child["authorIsChannelOwner"]?.try &.as_boolauthor_name += " <i class=\"icon ion ion-md-checkmark-circle\"></i>"elsif child["verified"]?.try &.as_boolauthor_name += " <i class=\"icon ion ion-md-checkmark\"></i>"end+ if child["isMember"]?.try &.as_bool+ member_icon = "<img+ alt=\"\"+ src=\"/ggpht#{URI.parse(child["memberIconUrl"].as_s).request_target}\"+ width=\"16\"+ height=\"16\"+ title=\"#{translate(locale, "Member")}\"+ />"+ endhtml << <<-END_HTML<div class="pure-g" style="width:100%"><div class="channel-profile pure-u-4-24 pure-u-md-2-24">@@ -343,6 +353,7 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false)<b><a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a></b>+ #{member_icon}<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>END_HTML@@ -678,13 +689,17 @@ def content_to_comment_html(content, video_id : String? = "")text = "<b>#{text}</b>" if run["bold"]?text = "<s>#{text}</s>" if run["strikethrough"]?text = "<i>#{text}</i>" if run["italics"]?- if emojiImage = run.dig?("emoji", "image")- emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text- emojiThumb = emojiImage["thumbnails"][0]- emojiUrl = "/ggpht#{URI.parse(emojiThumb["url"].as_s).request_target}"- emojiWidth = emojiThumb["width"]- emojiHeight = emojiThumb["height"]- text = "<img alt=\"#{emojiAlt}\" src=\"#{emojiUrl}\" width=\"#{emojiWidth}\" height=\"#{emojiHeight}\" style=\"margin-right:2px;margin-left:2px;\" />"+ if run["emoji"]?+ if run["emoji"]["isCustomEmoji"]?.try &.as_bool+ if emojiImage = run.dig?("emoji", "image")+ emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text+ emojiThumb = emojiImage["thumbnails"][0]+ text = "<img alt=\"#{emojiAlt}\" src=\"/ggpht#{URI.parse(emojiThumb["url"].as_s).request_target}\" title=\"#{emojiAlt}\" width=\"#{emojiThumb["width"]}\" height=\"#{emojiThumb["height"]}\" style=\"margin-right:2px;margin-left:2px;\"/>"+ else+ # Hide deleted channel emoji+ text = ""+ end+ endendtext