Skip to content

Commit

Permalink
Fix thumbnail labels wrong position
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Feb 22, 2024
1 parent f82fb79 commit dcbf11a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion maze-utils
14 changes: 7 additions & 7 deletions src/utils/thumbnails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function labelThumbnail(thumbnail: HTMLImageElement): Promise<HTMLE
return null;
}

const link = thumbnail.querySelector("a") as HTMLAnchorElement
const link = thumbnail.querySelector("a") as HTMLAnchorElement;
if (!link || !link.href) return null; // no link found
const videoID = parseBilibiliVideoIDFromURL(link.href)?.videoID;
if (!videoID) {
Expand Down Expand Up @@ -49,11 +49,11 @@ function hideThumbnailLabel(thumbnail: HTMLImageElement): void {
}

function createOrGetThumbnail(thumbnail: HTMLImageElement): { overlay: HTMLElement; text: HTMLElement } {
const oldElement = getOldThumbnailLabel(thumbnail);
if (oldElement) {
const oldLabelElement = getOldThumbnailLabel(thumbnail);
if (oldLabelElement) {
return {
overlay: oldElement as HTMLElement,
text: oldElement.querySelector("span") as HTMLElement
overlay: oldLabelElement as HTMLElement,
text: oldLabelElement.querySelector("span") as HTMLElement
};
}

Expand All @@ -71,10 +71,10 @@ function createOrGetThumbnail(thumbnail: HTMLImageElement): { overlay: HTMLEleme

const icon = createSBIconElement();
const text = document.createElement("span");
thumbnail.style.position = "relative";
overlay.appendChild(icon);
overlay.appendChild(text);
thumbnail.appendChild(overlay);
const labelAnchor = thumbnail.querySelector("img") ?? thumbnail;
labelAnchor.after(overlay);

return {
overlay,
Expand Down

0 comments on commit dcbf11a

Please sign in to comment.