mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
JS: Update timeupdate event defensive to prevent errors
This commit is contained in:
parent
1ae14cc224
commit
7214fdaff4
1 changed files with 18 additions and 12 deletions
|
@ -135,26 +135,32 @@ player.on('timeupdate', function () {
|
||||||
// YouTube links
|
// YouTube links
|
||||||
|
|
||||||
let elem_yt_watch = document.getElementById('link-yt-watch');
|
let elem_yt_watch = document.getElementById('link-yt-watch');
|
||||||
|
if (elem_yt_watch) {
|
||||||
|
let base_url_yt_watch = elem_yt_watch.getAttribute('data-base-url');
|
||||||
|
elem_yt_watch.href = addCurrentTimeToURL(base_url_yt_watch);
|
||||||
|
}
|
||||||
|
|
||||||
let elem_yt_embed = document.getElementById('link-yt-embed');
|
let elem_yt_embed = document.getElementById('link-yt-embed');
|
||||||
|
if (elem_yt_embed) {
|
||||||
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_yt_embed = elem_yt_embed.getAttribute('data-base-url');
|
elem_yt_embed.href = addCurrentTimeToURL(base_url_yt_embed);
|
||||||
|
}
|
||||||
elem_yt_watch.href = addCurrentTimeToURL(base_url_yt_watch);
|
|
||||||
elem_yt_embed.href = addCurrentTimeToURL(base_url_yt_embed);
|
|
||||||
|
|
||||||
// Invidious links
|
// Invidious links
|
||||||
|
|
||||||
let domain = window.location.origin;
|
let domain = window.location.origin;
|
||||||
|
|
||||||
let elem_iv_embed = document.getElementById('link-iv-embed');
|
let elem_iv_embed = document.getElementById('link-iv-embed');
|
||||||
|
if (elem_iv_embed) {
|
||||||
|
let base_url_iv_embed = elem_iv_embed.getAttribute('data-base-url');
|
||||||
|
elem_iv_embed.href = addCurrentTimeToURL(base_url_iv_embed, domain);
|
||||||
|
}
|
||||||
|
|
||||||
let elem_iv_other = document.getElementById('link-iv-other');
|
let elem_iv_other = document.getElementById('link-iv-other');
|
||||||
|
if (elem_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');
|
||||||
let base_url_iv_other = elem_iv_other.getAttribute('data-base-url');
|
elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other, domain);
|
||||||
|
}
|
||||||
elem_iv_embed.href = addCurrentTimeToURL(base_url_iv_embed, domain);
|
|
||||||
elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other, domain);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue