From 276d3bd4de603b1cdb073574e055e53a93e3514f Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sat, 21 Feb 2026 04:27:55 +0100 Subject: [PATCH] fix: implement non-blocking two-phase sync and hardened GCPD scraper for reliable cooldown tracking --- frontend/electron/services/scraper.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/frontend/electron/services/scraper.ts b/frontend/electron/services/scraper.ts index 9619c82..e470573 100644 --- a/frontend/electron/services/scraper.ts +++ b/frontend/electron/services/scraper.ts @@ -29,20 +29,25 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string): $('table').each((_, table) => { const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get(); - const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration')); + const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration') || h.includes('Cooldown Expiration')); if (expirationIndex !== -1) { - const firstRow = $(table).find('tr').not(':has(th)').first(); - const dateText = firstRow.find('td').eq(expirationIndex).text().trim(); - - if (dateText && dateText !== '') { - const cleanDateText = dateText.replace(' GMT', ' UTC'); - const parsed = new Date(cleanDateText); - - if (!isNaN(parsed.getTime())) { - expirationDate = parsed; + const rows = $(table).find('tr').not(':has(th)'); + rows.each((_, row) => { + const dateText = $(row).find('td').eq(expirationIndex).text().trim(); + if (dateText && dateText !== '') { + // Steam uses 'GMT' which some JS engines don't parse well, replace with 'UTC' + const cleanDateText = dateText.replace(' GMT', ' UTC'); + const parsed = new Date(cleanDateText); + + if (!isNaN(parsed.getTime())) { + // We want the newest expiration date found + if (!expirationDate || parsed > (expirationDate as Date)) { + expirationDate = parsed; + } + } } - } + }); } });