diff --git a/index.ts b/index.ts index f8db88b..75aa94f 100644 --- a/index.ts +++ b/index.ts @@ -14,24 +14,22 @@ async function getPatchHrefs() { let patchHrefs: string[] = []; - for (let i = 0; i <= 7; i++) { - const req = await fetch(getGalleryPageHref(i)); - const data = parse(await req.text()); + [...Array(7).keys()] + .map((val) => ++val) + .map(async (page) => { + 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(); - const links = gallery - ?.getElementsByTagName("a") - .map((el) => el.getAttribute("href")) - .filter((el) => el) as string[]; - - patchHrefs.push.apply(patchHrefs, links); - } - - return patchHrefs; + return gallery + ?.getElementsByTagName("a") + .map((el) => el.getAttribute("href")) + .filter((el) => el) as string[]; + }); } const allPatches = await getPatchHrefs();