From 2456b629365450970363e5cf0e9a65c1a24160ab Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 14 Sep 2023 20:50:17 +0200 Subject: [PATCH] Frontend: Add timestamp on invidious embed links --- assets/js/player.js | 15 +++++++++------ src/invidious/routes/watch.cr | 8 -------- src/invidious/views/watch.ecr | 12 +++++++++++- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index cd0e7a721..d07d6cf44 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -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); }); diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index e5cf37163..3d935f0ad 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -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) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index ac3fee65a..a768328a6 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -125,6 +125,7 @@ we're going to need to do it here in order to allow for translations. <%= translate(locale, "videoinfo_watch_on_youTube") %> (<%= translate(locale, "videoinfo_youTube_embed_link") %>) +

<% if env.get("preferences").as(Preferences).automatic_instance_redirect%> "><%= translate(locale, "Switch Invidious Instance") %> @@ -132,9 +133,18 @@ we're going to need to do it here in order to allow for translations. <%= translate(locale, "Switch Invidious Instance") %> <% end %>

+ +

<% if params.annotations %>