Skip to content

Commit 63fdac9

Browse files
authored
fixed icons
1 parent 341caa1 commit 63fdac9

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/ships/gallery.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ const handleSkinCategory = ({
8989
throw new Error(`${name} is missing skin ${skinName} on Skins page, but has skin in Gallery.`);
9090
};
9191

92+
const ICON_URL_TAILS = {
93+
"Icon.png": "icon",
94+
"ChibiIcon.png": "chibi",
95+
"Banner.png": "banner"
96+
};
97+
98+
function parseIcons(td: Element){
99+
return Array.from(td.querySelectorAll("img")).map(r=>{
100+
const url = galleryThumbnailUrlToActualUrl(r.getAttribute("src"));
101+
const urlType = Object.keys(ICON_URL_TAILS).find(pattern=>url.endsWith(pattern)) ?? "unknown"
102+
return {url, urlType}
103+
});
104+
}
105+
106+
92107
export async function fetchGallery(
93108
name: string,
94109
url: string
@@ -135,9 +150,9 @@ export async function fetchGallery(
135150
let value: any = row.getElementsByTagName("td")[0].textContent.trim();
136151

137152
if (key === "live2dModel") value = value === "Yes";
138-
if (key === "cost") value = parseInt(value);
139-
140-
if (ClientSkinNameHeaders[key]) {
153+
else if (key === "cost") value = parseInt(value);
154+
else if (key === "icons") value = parseIcons(row.getElementsByTagName("td"));
155+
else if (ClientSkinNameHeaders[key]) {
141156
// Because skins have different names on different clients,
142157
// each skin's Gallery page has a row for their localized name.
143158
// Next to that is the availability in that client.

0 commit comments

Comments
 (0)