mirror of
https://github.com/iv-org/invidious
synced 2024-11-24 03:53:27 +01:00
JS: Update external links exactly once per second
This commit is contained in:
parent
47cc9dc169
commit
40919c6a83
@ -114,12 +114,23 @@ function addCurrentTimeToURL(url, base) {
|
|||||||
return urlUsed;
|
return urlUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global variable to save the last timestamp (in full seconds) at which the external
|
||||||
|
* links were updated by the 'timeupdate' callback below.
|
||||||
|
*
|
||||||
|
* It is initialized to 5s so that the video will always restart from the beginning
|
||||||
|
* if the user hasn't really started watching before switching to the other website.
|
||||||
|
*/
|
||||||
|
var timeupdate_last_ts = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback that updates the timestamp on all external links
|
* Callback that updates the timestamp on all external links
|
||||||
*/
|
*/
|
||||||
player.on('timeupdate', function () {
|
player.on('timeupdate', function () {
|
||||||
// Only update once every 5 seconds
|
// Only update once every second
|
||||||
if ((Math.ceil(player.currentTime()) % 5) != 0) return;
|
let current_ts = Math.floor(player.currentTime());
|
||||||
|
if (current_ts > timeupdate_last_ts) timeupdate_last_ts = current_ts;
|
||||||
|
else return;
|
||||||
|
|
||||||
// YouTube links
|
// YouTube links
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user