JS: Fix missing domain in URL constructor

This commit is contained in:
Samantaz Fox 2023-09-27 23:01:25 +02:00
parent 700c57559b
commit 47cc9dc169
No known key found for this signature in database
GPG Key ID: F42821059186176E
1 changed files with 8 additions and 4 deletions

View File

@ -98,11 +98,13 @@ if (video_data.params.quality === 'dash') {
/** /**
* Function for add time argument to url * Function for add time argument to url
*
* @param {String} url * @param {String} url
* @param {String} [base]
* @returns {URL} urlWithTimeArg * @returns {URL} urlWithTimeArg
*/ */
function addCurrentTimeToURL(url) { function addCurrentTimeToURL(url, base) {
var urlUsed = new URL(url); var urlUsed = new URL(url, base);
urlUsed.searchParams.delete('start'); urlUsed.searchParams.delete('start');
var currentTime = Math.ceil(player.currentTime()); var currentTime = Math.ceil(player.currentTime());
if (currentTime > 0) if (currentTime > 0)
@ -132,14 +134,16 @@ player.on('timeupdate', function () {
// Invidious links // Invidious links
let domain = window.location.origin;
let elem_iv_embed = document.getElementById('link-iv-embed'); let elem_iv_embed = document.getElementById('link-iv-embed');
let elem_iv_other = document.getElementById('link-iv-other'); 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_embed = elem_iv_embed.getAttribute('data-base-url');
let base_url_iv_other = elem_iv_other.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_embed.href = addCurrentTimeToURL(base_url_iv_embed, domain);
elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other); elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other, domain);
}); });