diff --git a/index.ts b/index.ts index eb78b57..9035a8e 100644 --- a/index.ts +++ b/index.ts @@ -12,22 +12,28 @@ async function getPatchHrefs() { } } - [...Array(7).keys()] - .map((val) => ++val) - .map(async (page) => { - const req = await fetch(getGalleryPageHref(page)); - const data = parse(await req.text()); + return ( + await Promise.all( + [...Array(7).keys()] + .map((val) => ++val) + .map((page) => { + return (async () => { + const req = await fetch(getGalleryPageHref(page)); + const data = parse(await req.text()); - const gallery = data - .getElementsByTagName("div") - .filter((el) => el.classList.contains("hds-gallery-items")) - .shift(); + const gallery = data + .getElementsByTagName("div") + .filter((el) => el.classList.contains("hds-gallery-items")) + .shift(); - return gallery - ?.getElementsByTagName("a") - .map((el) => el.getAttribute("href")) - .filter((el) => el) as string[]; - }); + return gallery + ?.getElementsByTagName("a") + .map((el) => el.getAttribute("href")) + .filter((el) => el) as string[]; + })(); + }), + ) + ).flat(); } const allPatches = await getPatchHrefs();