From 7d3bf4f4ce1dd38e828faa494469911bd0791514 Mon Sep 17 00:00:00 2001 From: TrisTOON <36267812+TrisTOON@users.noreply.github.com> Date: Wed, 12 Nov 2025 17:06:49 +0100 Subject: [PATCH] Fixes the retrieval of the iOS version --- src/commands/update.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/commands/update.ts b/src/commands/update.ts index 8ea1bfc..7a93c57 100644 --- a/src/commands/update.ts +++ b/src/commands/update.ts @@ -71,21 +71,19 @@ async function fetchAndroidData(): Promise { async function fetchIosData(): Promise { const response: Response = await fetch("https://apps.apple.com/app/id1531842415"); const {window}: JSDOM = new JSDOM(await response.text()); - const scripts: HTMLElement[] = [...window.document.querySelectorAll("body > script")]; + const scripts: HTMLElement[] = [...window.document.querySelectorAll("body script")]; for (const {textContent} of scripts) { - if (textContent == null || !textContent.startsWith("{\"") || !textContent.endsWith("}")) { + if (textContent == null || !textContent.startsWith("[") || !textContent.endsWith("]")) { continue; } try { - const json: string = `${Object.entries(JSON.parse(textContent)).filter((entry: [string, any]): boolean => { - return entry[0].includes("1531842415"); - })[0][1]}`; + const json: string = textContent; const result: any = JSON.parse(json); return { title: "iOS", link: "https://apps.apple.com/app/id1531842415", - version: parseVersion(result.d[0].attributes.platformAttributes.ios.versionHistory[0].versionDisplay), - date: new Date(result.d[0].attributes.platformAttributes.ios.versionHistory[0].releaseTimestamp), + version: parseVersion(result[0].data.shelfMapping.mostRecentVersion.seeAllAction.pageData.shelves[0].items[0].primarySubtitle), + date: new Date(result[0].data.shelfMapping.mostRecentVersion.seeAllAction.pageData.shelves[0].items[0].secondarySubtitle), }; } catch {} } @@ -100,7 +98,7 @@ async function fetchSwitchData(): Promise { continue; } try { - const json: string = textContent.slice(textContent.indexOf("{\"pageProps\":") + 13, textContent.lastIndexOf(",\"__N_SSP\":")); + const json: string = textContent.slice(textContent.indexOf("{\"pageProps\":") + 13, textContent.lastIndexOf(",\"__N_SSP\":")); const result: any = JSON.parse(json); return { title: "Switch",