fix: implement non-blocking two-phase sync and hardened GCPD scraper for reliable cooldown tracking

This commit is contained in:
2026-02-21 04:27:55 +01:00
parent 34a71de2dc
commit 276d3bd4de

View File

@@ -29,20 +29,25 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string):
$('table').each((_, table) => { $('table').each((_, table) => {
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get(); 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) { if (expirationIndex !== -1) {
const firstRow = $(table).find('tr').not(':has(th)').first(); const rows = $(table).find('tr').not(':has(th)');
const dateText = firstRow.find('td').eq(expirationIndex).text().trim(); 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 (dateText && dateText !== '') { if (!isNaN(parsed.getTime())) {
const cleanDateText = dateText.replace(' GMT', ' UTC'); // We want the newest expiration date found
const parsed = new Date(cleanDateText); if (!expirationDate || parsed > (expirationDate as Date)) {
expirationDate = parsed;
if (!isNaN(parsed.getTime())) { }
expirationDate = parsed; }
} }
} });
} }
}); });