kopia lustrzana https://github.com/iv-org/invidious
Other minor fixes
rodzic
e690e166b0
commit
b0342b7449
|
@ -13,20 +13,23 @@
|
||||||
// For dynamically inserted elements
|
// For dynamically inserted elements
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', function (e) {
|
||||||
if (!e || !e.target) { return; }
|
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) {
|
switch (handler_name) {
|
||||||
case 'jump_to_time':
|
case 'jump_to_time':
|
||||||
var time = e.getAttribute('data-jump-time');
|
e.preventDefault();
|
||||||
|
var time = t.getAttribute('data-jump-time');
|
||||||
player.currentTime(time);
|
player.currentTime(time);
|
||||||
break;
|
break;
|
||||||
case 'get_youtube_replies':
|
case 'get_youtube_replies':
|
||||||
var load_more = e.getAttribute('data-load-more') !== null;
|
var load_more = t.getAttribute('data-load-more') !== null;
|
||||||
var load_replies = e.getAttribute('data-load-replies') !== null;
|
var load_replies = t.getAttribute('data-load-replies') !== null;
|
||||||
get_youtube_replies(e, load_more, load_replies);
|
get_youtube_replies(t, load_more, load_replies);
|
||||||
break;
|
break;
|
||||||
case 'toggle_parent':
|
case 'toggle_parent':
|
||||||
toggle_parent(e);
|
toggle_parent(t);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -560,30 +560,21 @@ def parse_content(content : JSON::Any, video_id : String? = "") : String
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_to_comment_html(content, video_id : String? = "")
|
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)
|
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 run["navigationEndpoint"]?
|
||||||
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
|
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
|
||||||
url = URI.parse(url)
|
url = URI.parse(url)
|
||||||
displayed_url = url
|
displayed_url = text
|
||||||
|
|
||||||
if url.host == "youtu.be"
|
if url.host == "youtu.be"
|
||||||
url = "/watch?v=#{url.request_target.lstrip('/')}"
|
url = "/watch?v=#{url.request_target.lstrip('/')}"
|
||||||
displayed_url = "youtube.com#{url}"
|
|
||||||
elsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com")
|
elsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com")
|
||||||
if url.path == "/redirect"
|
if url.path == "/redirect"
|
||||||
# Sometimes, links can be corrupted (why?) so make sure to fallback
|
# Sometimes, links can be corrupted (why?) so make sure to fallback
|
||||||
# nicely. See https://github.com/iv-org/invidious/issues/2682
|
# 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
|
displayed_url = url
|
||||||
else
|
else
|
||||||
url = url.request_target
|
url = url.request_target
|
||||||
|
@ -623,10 +614,13 @@ def content_to_comment_html(content, video_id : String? = "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
text
|
text = "<b>#{text}</b>" if run["bold"]?
|
||||||
end.join("").delete('\ufeff')
|
text = "<i>#{text}</i>" if run["italics"]?
|
||||||
|
|
||||||
return comment_html
|
text
|
||||||
|
end
|
||||||
|
|
||||||
|
return html_array.join("").delete('\ufeff')
|
||||||
end
|
end
|
||||||
|
|
||||||
def produce_comment_continuation(video_id, cursor = "", sort_by = "top")
|
def produce_comment_continuation(video_id, cursor = "", sort_by = "top")
|
||||||
|
|
Ładowanie…
Reference in New Issue