Frontend: Add timestamp on invidious embed links

このコミットが含まれているのは:
Samantaz Fox 2023-09-14 20:50:17 +02:00
コミット 2456b62936
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: F42821059186176E
3個のファイルの変更20行の追加15行の削除

ファイルの表示

@ -116,14 +116,17 @@ function addCurrentTimeToURL(url) {
* Timer that updates the timestamp on "watch on youtube" and "embed" links
*/
player.ready(function () {
let elem_watch = document.getElementById('link-yt-watch');
let elem_embed = document.getElementById('link-yt-embed');
let elem_yt_watch = document.getElementById('link-yt-watch');
let elem_yt_embed = document.getElementById('link-yt-embed');
let elem_iv_embed = document.getElementById('link-iv-embed');
let base_url_watch = elem_watch.getAttribute('data-base-url');
let base_url_embed = elem_embed.getAttribute('data-base-url');
let base_url_yt_watch = elem_yt_watch.getAttribute('data-base-url');
let base_url_yt_embed = elem_yt_embed.getAttribute('data-base-url');
let base_url_iv_embed = elem_iv_embed.getAttribute('data-base-url');
setTimeout(() => { elem_watch.setAttribute('href') = addCurrentTimeToURL(base_url_watch); }, 5000);
setTimeout(() => { elem_embed.setAttribute('href') = addCurrentTimeToURL(base_url_embed); }, 5000);
setTimeout(() => { elem_yt_watch.setAttribute('href') = addCurrentTimeToURL(base_url_yt_watch); }, 5000);
setTimeout(() => { elem_yt_embed.setAttribute('href') = addCurrentTimeToURL(base_url_yt_embed); }, 5000);
setTimeout(() => { elem_iv_embed.setAttribute('href') = addCurrentTimeToURL(base_url_iv_embed); }, 5000);
});

ファイルの表示

@ -30,14 +30,6 @@ module Invidious::Routes::Watch
return env.redirect "/"
end
embed_link = "/embed/#{id}"
if env.params.query.size > 1
embed_params = HTTP::Params.parse(env.params.query.to_s)
embed_params.delete_all("v")
embed_link += "?"
embed_link += embed_params.to_s
end
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
continuation = process_continuation(env.params.query, plid, id)

ファイルの表示

@ -125,6 +125,7 @@ we're going to need to do it here in order to allow for translations.
<a id="link-yt-watch" data-base-url="<%= link_yt_watch %>" href="<%= link_yt_watch %>"><%= translate(locale, "videoinfo_watch_on_youTube") %></a>
(<a id="link-yt-embed" data-base-url="<%= link_yt_embed %>" href="<%= link_yt_embed %>"><%= translate(locale, "videoinfo_youTube_embed_link") %></a>)
</span>
<p id="watch-on-another-invidious-instance">
<% if env.get("preferences").as(Preferences).automatic_instance_redirect%>
<a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Switch Invidious Instance") %></a>
@ -132,9 +133,18 @@ we're going to need to do it here in order to allow for translations.
<a href="https://redirect.invidious.io<%= env.request.resource %>"><%= translate(locale, "Switch Invidious Instance") %></a>
<% end %>
</p>
<p id="embed-link">
<a href="<%= embed_link %>"><%= translate(locale, "videoinfo_invidious_embed_link") %></a>
<%-
params_iv_embed = env.params.query.dup
params_iv_embed.delete_all("v")
link_iv_embed = URI.new(path: "/embed/#{id}")
link_iv_embed = IV::HttpServer::Utils.add_params_to_url(link_iv_embed, params_iv_embed)
-%>
<a id="link-iv-embed" data-base-url="<%= link_iv_embed %>" href="<%= link_iv_embed %>"><%= translate(locale, "videoinfo_invidious_embed_link") %></a>
</p>
<p id="annotations">
<% if params.annotations %>
<a href="/watch?<%= env.params.query %>&iv_load_policy=3">