refactor: replace all youtube external links with confirmation page

This commit is contained in:
unlxam 2024-08-24 13:01:37 -03:00
parent 01e9fa3af7
commit 0fd38e52ef
4 changed files with 17 additions and 4 deletions

View File

@ -157,8 +157,10 @@ module Invidious::Frontend::Comments
|
END_HTML
elsif comments["authorId"]?
permalink = "https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}"
permalink_confirm = "/confirm_leave?link=#{URI.encode_path(permalink)}"
html << <<-END_HTML
<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
<a href="#{permalink_confirm}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
END_HTML
end

View File

@ -180,6 +180,9 @@ def error_redirect_helper(env : HTTP::Server::Context)
go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube")
switch_instance = translate(locale, "Switch Invidious Instance")
youtube_link = "https://youtube.com#{env.request.resource}"
youtube_link_confirm = "/confirm_leave?link=#{URI.encode_path(youtube_link)}"
return <<-END_HTML
<p style="margin-bottom: 4px;">#{next_steps_text}</p>
<ul>
@ -190,7 +193,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
<a href="/redirect?referer=#{env.get("current_page")}">#{switch_instance}</a>
</li>
<li>
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
<a href="#{youtube_link_confirm}">#{go_to_youtube}</a>
</li>
</ul>
END_HTML

View File

@ -1,6 +1,10 @@
<div class="flex-right flexible">
<div class="icon-buttons">
<a title="<%=translate(locale, "videoinfo_watch_on_youTube")%>" rel="noreferrer noopener" href="https://www.youtube.com/watch<%=endpoint_params%>">
<%-
watch_yt = "https://www.youtube.com/watch#{endpoint_params}"
confirm_watch_yt = "/confirm_leave?link=#{URI.encode_path(watch_yt)}"
-%>
<a title="<%=translate(locale, "videoinfo_watch_on_youTube")%>" href="<%= confirm_watch_yt %>">
<i class="icon ion-logo-youtube"></i>
</a>
<a title="<%=translate(locale, "Audio mode")%>" href="/watch<%=endpoint_params%>&listen=1">

View File

@ -83,7 +83,11 @@
<% if !playlist.is_a? InvidiousPlaylist %>
<div class="pure-u-2-3">
<a rel="noreferrer noopener" href="https://www.youtube.com/playlist?list=<%= playlist.id %>">
<%-
view_yt = "https://www.youtube.com/playlist?list=#{playlist.id}"
confirm_view_yt = "/confirm_leave?link=#{URI.encode_path(view_yt)}"
-%>
<a href="<%= confirm_view_yt %>">
<%= translate(locale, "View playlist on YouTube") %>
</a>
<span> | </span>