From 6c08b8a553d1ed5dcfcdb18220b901a008d7d2cb Mon Sep 17 00:00:00 2001 From: goodtube4u Date: Tue, 30 Sep 2025 10:53:36 +1000 Subject: [PATCH] Always play videos from the start option --- README.md | 1 + goodtube.js | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cff79cb..869ea78 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ It also provides a few additional options: - Hide end screen suggested videos - Hide sidebar suggested videos - Hide comments +- Always play videos from the start *These can be accessed via the custom settings menu. You will find this down the bottom right of Youtube when installed.* diff --git a/goodtube.js b/goodtube.js index 71ae54b..643c08a 100644 --- a/goodtube.js +++ b/goodtube.js @@ -210,6 +210,13 @@ goodTube_hideComments = 'false'; } + // Always play videos from the start? + let goodTube_alwaysStart = goodTube_helper_getCookie('goodTube_alwaysStart'); + if (!goodTube_alwaysStart) { + goodTube_helper_setCookie('goodTube_alwaysStart', 'false'); + goodTube_alwaysStart = 'false'; + } + // Is autoplay turned on? let goodTube_autoplay = goodTube_helper_getCookie('goodTube_autoplay'); if (!goodTube_autoplay) { @@ -782,9 +789,11 @@ // Setup the starting time let startTime = 0; - // Include the startime time from query params - if (typeof goodTube_getParams['t'] !== 'undefined') { - startTime = parseFloat(goodTube_getParams['t'].replace('s', '')); + // Include the startime time from query params (if enabled) + if (goodTube_alwaysStart === 'false') { + if (typeof goodTube_getParams['t'] !== 'undefined') { + startTime = parseFloat(goodTube_getParams['t'].replace('s', '')); + } } @@ -830,7 +839,9 @@ } // Sync the starting time - goodTube_player_syncStartingTime(); + if (goodTube_alwaysStart === 'false') { + goodTube_player_syncStartingTime(); + } // Set the Youtube player to auto quality goodTube_player_setQualitySucceeded = false; @@ -1726,6 +1737,11 @@ hideComments = ' checked'; } + let alwaysStart = ''; + if (goodTube_alwaysStart === 'true') { + alwaysStart = ' checked'; + } + // Add content to the menu container menuContainer.innerHTML = ` +
+ + +
+ @@ -2287,6 +2308,17 @@ } } + // Always play videos from the start + let goodTube_setting_alwaysStart = document.querySelector('.goodTube_option_alwaysStart'); + if (goodTube_setting_alwaysStart) { + if (goodTube_setting_alwaysStart.checked) { + goodTube_helper_setCookie('goodTube_alwaysStart', 'true'); + } + else { + goodTube_helper_setCookie('goodTube_alwaysStart', 'false'); + } + } + // Refresh the page window.location.href = window.location.href; });