mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-09 20:24:03 +00:00
Add watch indicators (#3383)
This commit is contained in:
@@ -145,6 +145,24 @@ img.thumbnail {
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
div.watched-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(255,255,255,.4);
|
||||
}
|
||||
|
||||
div.watched-indicator {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 4px;
|
||||
width: 100%;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.length {
|
||||
z-index: 100;
|
||||
position: absolute;
|
||||
|
24
assets/js/watched_indicator.js
Normal file
24
assets/js/watched_indicator.js
Normal file
@@ -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 + '%';
|
||||
});
|
Reference in New Issue
Block a user