Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@
},
"hideSponsoredVideosOnHome": {
"message": "Hide sponsored videos on Home page"
},
"hidePauseOverlay": {
"message": "Hide Pause Overlay"
},
Expand Down
47 changes: 29 additions & 18 deletions js&css/web-accessible/www.youtube.com/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,37 @@ ImprovedTube.formatSecond = function (rTime) {
};

ImprovedTube.playerRemainingDuration = function () {
//If is a live stream, do not show remaining time
const button = document.querySelector('button.ytp-live-badge.ytp-button.ytp-live-badge-is-livehead');
if (button)
return;

var duration = document.querySelector(".ytp-time-duration").innerText;
var current = document.querySelector(".ytp-time-current").innerText;
document.querySelector('.ytp-time-contents').style.setProperty('display', 'none', 'important');
var player = ImprovedTube.elements.player;
var rTime = ImprovedTube.formatSecond((player.getDuration() - player.getCurrentTime()).toFixed(0));
var element = document.querySelector(".ytp-time-remaining-duration");
if (!element) {
var label = document.createElement("span");
label.textContent = current + " / " + duration + " / (-" + rTime + ")";
label.className = "ytp-time-remaining-duration";
document.querySelector(".ytp-time-display span").appendChild(label);
} else {
return element.textContent = current + " / " + duration + " (-" + rTime + ")";
const liveBadge = document.querySelector('button.ytp-live-badge.ytp-button.ytp-live-badge-is-livehead');
if (liveBadge) return;

const currentEl = document.querySelector('.ytp-time-current');
const durationEl = document.querySelector('.ytp-time-duration');

if (!currentEl || !durationEl) return;

const player = ImprovedTube.elements.player;
if (!player) return;

const currentTime = player.getCurrentTime();
const duration = player.getDuration();

if (!isFinite(duration) || !isFinite(currentTime) || duration <= 0) return;

const remainingSeconds = Math.max(0, duration - currentTime);
const rTime = ImprovedTube.formatSecond(Math.floor(remainingSeconds));

if (!rTime || rTime.includes('NaN')) return;

if (!durationEl.dataset.itOriginal) {
durationEl.dataset.itOriginal = durationEl.textContent;
}

// Overwrite text
durationEl.textContent =
durationEl.dataset.itOriginal + ' (-' + rTime + ')';
};


/*------------------------------------------------------------------------------
Comments Sidebar Simple
------------------------------------------------------------------------------*/
Expand Down
8 changes: 1 addition & 7 deletions menu/skeleton-parts/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ extension.skeleton.main.layers.section.appearance.on.click.player = {
component: "switch",
text: "hideTopLoadingBar",
tags: "remove,hide"
},
}

},
hide_gradient_bottom: {
component: "switch",
Expand Down Expand Up @@ -522,12 +522,6 @@ extension.skeleton.main.layers.section.appearance.on.click.player = {
value: false,
tags: "remove,hide,pause,bezel"
},
player_remaining_duration: {
component: "switch",
text: "showRemainingDuration",
id: "show-remaining-duration",
value: false
},
duration_with_speed: {
component: "switch",
text: "durationWithSpeed",
Expand Down
Loading