From fe18e92891c67c6368d052618c8b10a1841615bc Mon Sep 17 00:00:00 2001 From: mehbark Date: Wed, 12 Jun 2024 19:59:50 -0400 Subject: [PATCH] fix: hs2 last update page count --- serverside/hs2-last-updated.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/serverside/hs2-last-updated.ts b/serverside/hs2-last-updated.ts index 5ed042e..008826a 100644 --- a/serverside/hs2-last-updated.ts +++ b/serverside/hs2-last-updated.ts @@ -22,7 +22,7 @@ async function get_last_update_date(): Promise< { last_updated: Date; last_update_count: number } | string > { try { - const res = await fetch("https://homestuck2.com/log"); + const res = await fetch("https://homestuck2.com/story/log"); const body = await res.text(); if (!body) return "couldn't get a string body"; @@ -32,14 +32,18 @@ async function get_last_update_date(): Promise< const time = doc.querySelector("time"); if (!time) return "couldn't get even a single time from the doc (bad!)"; + console.log(time.attributes.getNamedItem("datetime")?.value); const datetime = time.attributes.getNamedItem("datetime")?.value; if (!datetime) return "time didn't have datetime attr??"; const date = new Date(datetime); + // should work until the year 10000 + // includes the hour for safety (NVM: WHAT IF IT ROLLED OVER (ugh let's hope that doesn't happen for the day)) + const date_prefix = date.toISOString().slice(0, 10); return { last_updated: date, last_update_count: - doc.querySelectorAll(`time[datetime="${date.toISOString()}"]`) + doc.querySelectorAll(`time[datetime^="${date_prefix}"]`) .length, }; } catch (e) {