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; + } + } } - } + }); } });