diff options
| author | Gavin <57272374+thtmnisamnstr@users.noreply.github.com> | 2023-04-03 17:09:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-03 17:09:34 -0700 |
| commit | c421f1f205eba08ca38b70833a9cc3aec72df36f (patch) | |
| tree | 91ec4b9e52aa766aaef412d83c3dd477e9aae39a /assets/js/watched_indicator.js | |
| parent | fffdaa1410db7f9b5c67b1b47d401a2744e7b220 (diff) | |
| parent | 8db2a93827a4e27a55a9095be15083ea68cdd571 (diff) | |
| download | invidious-c421f1f205eba08ca38b70833a9cc3aec72df36f.tar.gz invidious-c421f1f205eba08ca38b70833a9cc3aec72df36f.tar.bz2 invidious-c421f1f205eba08ca38b70833a9cc3aec72df36f.zip | |
Merge branch 'iv-org:master' into youtube-playlist-import
Diffstat (limited to 'assets/js/watched_indicator.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 + '%'; +}); |
