From c5cdfe4cf82c8655011aec9b14cf3a43bea189cc Mon Sep 17 00:00:00 2001 From: Vandern Rodrigues Date: Fri, 26 Jul 2024 23:50:18 +0100 Subject: [PATCH] Release v2.1.4 (#56) * fix bug with isUnavailableVideo function related to unavailable channel names --- CHANGELOG.md | 15 +++++++++++++++ package.json | 2 +- src/main.js | 18 +++++++++++------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a065f..b101b81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.1.4] - 2024-07-26 + +### Removed + +- Removed code which checks whether the video has a channel name from the + `isVideoUnavailable` function + - Found a rare situation where a + [video](https://www.youtube.com/watch?v=QwtyIDmhxh4) (as of 2024-07-26) had + a valid title and timestamp but no channel name + - This incorrectly flagged the video as "unavailable" + - The `checkPlaylistReady` function relies on the count of unavailable videos + & timestamps to determine whether a playlist is ready to be processed + - The video being incorrectly flagged, led to one count being higher than the + other, and so the extension determined the playlist was "not ready" + ## [v2.1.3] - 2024-07-12 ### Added diff --git a/package.json b/package.json index 8bf6302..d3b31b2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "An extension to calculate & display the total duration of a youtube playlist.", "author": "nrednav", "private": true, - "version": "2.1.3", + "version": "2.1.4", "type": "module", "engines": { "node": ">=20", diff --git a/src/main.js b/src/main.js index 03fe3de..dadaca7 100644 --- a/src/main.js +++ b/src/main.js @@ -21,7 +21,9 @@ const checkPlaylistReady = () => { let pollCount = 0; let playlistPoll = setInterval(() => { - if (pollCount >= maxPollCount) clearInterval(playlistPoll); + if (pollCount >= maxPollCount) { + clearInterval(playlistPoll); + } const playlistElement = document.querySelector(elementSelectors.playlist); const playlistExists = playlistElement !== null; @@ -50,11 +52,13 @@ const checkPlaylistReady = () => { const timestampElement = document.querySelector(elementSelectors.timestamp); const timestampExists = timestampElement !== null; + const unavailableTimestampsCount = countUnavailableTimestamps(); + const unavailableVideosCount = countUnavailableVideos(); if ( playlistExists && timestampExists && - countUnavailableTimestamps() === countUnavailableVideos() + unavailableTimestampsCount === unavailableVideosCount ) { clearInterval(playlistPoll); @@ -208,6 +212,11 @@ const countUnavailableVideos = () => { /** * Checks whether a given video element meets the criteria for being considered * "unavailable" + * + * Criteria: + * - Has no timestamp + * - Title is unavailable + * * @param {Element} video */ const isVideoUnavailable = (video) => { @@ -227,11 +236,6 @@ const isVideoUnavailable = (video) => { if (hasUnavailableTitle) return true; - const hasNoChannelName = - video.querySelector(elementSelectors.channelName)?.innerText.trim() === ""; - - if (hasNoChannelName) return true; - return false; };