Skip to content

Commit

Permalink
handle multiple thumbnail label insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Jan 15, 2025
1 parent 77c548e commit a26d296
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/thumbnail-utils/thumbnails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ export async function labelThumbnail(thumbnail: HTMLElement, containerType: stri
}

function getOldThumbnailLabel(thumbnail: HTMLElement): HTMLElement | null {
const allOldLabels = thumbnail.querySelectorAll("#sponsorThumbnailLabel");
if (allOldLabels.length > 1) {
// remove all but the last one
allOldLabels.forEach((label, index) => {
if (index !== allOldLabels.length - 1) {
label.remove();
}
});
}
return thumbnail.querySelector("#sponsorThumbnailLabel") as HTMLElement | null;
}

Expand Down

0 comments on commit a26d296

Please sign in to comment.