diff --git a/assets/js/handlers.js b/assets/js/handlers.js
index 3224e668..f6617b60 100644
--- a/assets/js/handlers.js
+++ b/assets/js/handlers.js
@@ -13,20 +13,23 @@
// For dynamically inserted elements
document.addEventListener('click', function (e) {
if (!e || !e.target) { return; }
- e = e.target;
- var handler_name = e.getAttribute('data-onclick');
+
+ var t = e.target;
+ var handler_name = t.getAttribute('data-onclick');
+
switch (handler_name) {
case 'jump_to_time':
- var time = e.getAttribute('data-jump-time');
+ e.preventDefault();
+ var time = t.getAttribute('data-jump-time');
player.currentTime(time);
break;
case 'get_youtube_replies':
- var load_more = e.getAttribute('data-load-more') !== null;
- var load_replies = e.getAttribute('data-load-replies') !== null;
- get_youtube_replies(e, load_more, load_replies);
+ var load_more = t.getAttribute('data-load-more') !== null;
+ var load_replies = t.getAttribute('data-load-replies') !== null;
+ get_youtube_replies(t, load_more, load_replies);
break;
case 'toggle_parent':
- toggle_parent(e);
+ toggle_parent(t);
break;
default:
break;
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 8e0d8a96..91ea8607 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -560,30 +560,21 @@ def parse_content(content : JSON::Any, video_id : String? = "") : String
end
def content_to_comment_html(content, video_id : String? = "")
- comment_html = content.map do |run|
+ html_array = content.map do |run|
text = HTML.escape(run["text"].as_s)
- if run["bold"]?
- text = "#{text}"
- end
-
- if run["italics"]?
- text = "#{text}"
- end
-
if run["navigationEndpoint"]?
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
url = URI.parse(url)
- displayed_url = url
+ displayed_url = text
if url.host == "youtu.be"
url = "/watch?v=#{url.request_target.lstrip('/')}"
- displayed_url = "youtube.com#{url}"
elsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com")
if url.path == "/redirect"
# Sometimes, links can be corrupted (why?) so make sure to fallback
# nicely. See https://github.com/iv-org/invidious/issues/2682
- url = HTTP::Params.parse(url.query.not_nil!)["q"]? || ""
+ url = url.query_params["q"]? || ""
displayed_url = url
else
url = url.request_target
@@ -623,10 +614,13 @@ def content_to_comment_html(content, video_id : String? = "")
end
end
- text
- end.join("").delete('\ufeff')
+ text = "#{text}" if run["bold"]?
+ text = "#{text}" if run["italics"]?
- return comment_html
+ text
+ end
+
+ return html_array.join("").delete('\ufeff')
end
def produce_comment_continuation(video_id, cursor = "", sort_by = "top")