mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Other minor fixes
This commit is contained in:
parent
e690e166b0
commit
b0342b7449
2 changed files with 19 additions and 22 deletions
|
@ -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;
|
||||
|
|
|
@ -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 = "<b>#{text}</b>"
|
||||
end
|
||||
|
||||
if run["italics"]?
|
||||
text = "<i>#{text}</i>"
|
||||
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 = "<b>#{text}</b>" if run["bold"]?
|
||||
text = "<i>#{text}</i>" 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")
|
||||
|
|
Loading…
Reference in a new issue