diff options
| author | Paul Fauchon <paul@fauchon.dev> | 2023-03-05 04:53:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-05 04:53:32 +0800 |
| commit | f6c6c9e5ec8bd4df8a0fe464f8393f5b967b31f9 (patch) | |
| tree | 307966e5780d7f99edcbb704c271080e8921cbfe /assets/js | |
| parent | 7993784701686c057b85c57704537135e6326de9 (diff) | |
| parent | bff5c8d9a19e1bcac83e787c0181bb2450ba921d (diff) | |
| download | invidious-f6c6c9e5ec8bd4df8a0fe464f8393f5b967b31f9.tar.gz invidious-f6c6c9e5ec8bd4df8a0fe464f8393f5b967b31f9.tar.bz2 invidious-f6c6c9e5ec8bd4df8a0fe464f8393f5b967b31f9.zip | |
Merge pull request #1 from iv-org/master
rebase
Diffstat (limited to 'assets/js')
| -rw-r--r-- | assets/js/watched_indicator.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/assets/js/watched_indicator.js b/assets/js/watched_indicator.js new file mode 100644 index 00000000..e971cd80 --- /dev/null +++ b/assets/js/watched_indicator.js @@ -0,0 +1,24 @@ +'use strict'; +var save_player_pos_key = 'save_player_pos'; + +function get_all_video_times() { + return helpers.storage.get(save_player_pos_key) || {}; +} + +document.querySelectorAll('.watched-indicator').forEach(function (indicator) { + var watched_part = get_all_video_times()[indicator.dataset.id]; + var total = parseInt(indicator.dataset.length, 10); + if (watched_part === undefined) { + watched_part = total; + } + var percentage = Math.round((watched_part / total) * 100); + + if (percentage < 5) { + percentage = 5; + } + if (percentage > 90) { + percentage = 100; + } + + indicator.style.width = percentage + '%'; +}); |
