Skip to content

Commit

Permalink
Release v2.1.4 (#56)
Browse files Browse the repository at this point in the history
* fix bug with isUnavailableVideo function related to unavailable channel names
  • Loading branch information
nrednav authored Jul 26, 2024
1 parent 4123047 commit c5cdfe4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 11 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) => {
Expand All @@ -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;
};

Expand Down

0 comments on commit c5cdfe4

Please sign in to comment.