Skip to content

Commit

Permalink
JS: Fix missing domain in URL constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
SamantazFox committed Sep 27, 2023
1 parent 700c575 commit 1ff82a7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions assets/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ if (video_data.params.quality === 'dash') {

/**
* Function for add time argument to url
*
* @param {String} url
* @param {String} [base]
* @returns {URL} urlWithTimeArg
*/
function addCurrentTimeToURL(url) {
var urlUsed = new URL(url);
function addCurrentTimeToURL(url, base) {
var urlUsed = new URL(url, base);
urlUsed.searchParams.delete('start');
var currentTime = Math.ceil(player.currentTime());
if (currentTime > 0)
Expand All @@ -127,19 +129,21 @@ player.on('timeupdate', function () {
let base_url_yt_watch = elem_yt_watch.getAttribute('data-base-url');
let base_url_yt_embed = elem_yt_embed.getAttribute('data-base-url');

elem_yt_watch.href = addCurrentTimeToURL(base_url_yt_watch);
elem_yt_embed.href = addCurrentTimeToURL(base_url_yt_embed);
elem_yt_watch.setAttribute('href') = addCurrentTimeToURL(base_url_yt_watch);
elem_yt_embed.setAttribute('href') = addCurrentTimeToURL(base_url_yt_embed);

// Invidious links

let domain = window.location.origin;

let elem_iv_embed = document.getElementById('link-iv-embed');
let elem_iv_other = document.getElementById('link-iv-other');

let base_url_iv_embed = elem_iv_embed.getAttribute('data-base-url');
let base_url_iv_other = elem_iv_other.getAttribute('data-base-url');

elem_iv_embed.href = addCurrentTimeToURL(base_url_iv_embed);
elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other);
elem_iv_embed.setAttribute('href') = addCurrentTimeToURL(base_url_iv_embed, domain);
elem_iv_other.setAttribute('href') = addCurrentTimeToURL(base_url_iv_other, domain);
});


Expand Down

0 comments on commit 1ff82a7

Please sign in to comment.