refactor: return early if feature is disabled

This commit is contained in:
Gus Libens 2025-11-13 20:12:26 +01:00
parent b83dbbaf2c
commit 004ed27f90
No known key found for this signature in database
GPG Key ID: 032E49D0FE9D51EA

View File

@ -193,14 +193,17 @@ player.on('timeupdate', function () {
elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other, domain); elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other, domain);
} }
// Check if the feature is enabled
const $markWatchedAfterDuration = document.getElementById(`${STORAGE_MARK_WATCHED_AFTER_DURATION}_pref`);
const markWatchedAfterDuration = $markWatchedAfterDuration?.innerText === "true";
if (!markWatchedAfterDuration) return;
// Only increase time watched when the time difference is one second and the video has not been marked as watched // Only increase time watched when the time difference is one second and the video has not been marked as watched
const isOneSecondDifference = current_ts - last_player_time === 1; const isOneSecondDifference = current_ts - last_player_time === 1;
const exceedsMarkWatchedAfterDuration = time_watched > MARK_WATCHED_AFTER_DURATION; const exceedsMarkWatchedAfterDuration = time_watched > MARK_WATCHED_AFTER_DURATION;
const $markWatchedAfterDuration = document.getElementById(`${STORAGE_MARK_WATCHED_AFTER_DURATION}_pref`); if (!isOneSecondDifference || exceedsMarkWatchedAfterDuration) return;
const markWatchedAfterDuration = $markWatchedAfterDuration?.innerText === "true";
if (!isOneSecondDifference || exceedsMarkWatchedAfterDuration || markWatchedAfterDuration === false) return;
time_watched += 1; time_watched += 1;