1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource https://esm.sh/preact */
import { activeGTrainAlerts } from "https://esm.town/v/pbt/gtrainalerts?v=36";
import { render } from "npm:preact-render-to-string";
import Uwuifier from "npm:uwuifier";
export default async function(req: Request) {
const uwuifier = new Uwuifier();
const query = new URL(req.url).searchParams;
const timestamp = query.get("at");
const uwu = query.get("uwu");
const parsedTimestamp = timestamp ? Number.parseInt(timestamp, 10) : Date.now();
const entities = await activeGTrainAlerts(parsedTimestamp);
const fucked = entities.length > 0;
const soFucked = entities.length > 1;
const howFucked = soFucked ? `s${entities.map(e => "o").join("")} fucked` : "fucked";
const title = `${uwu ? "UwU! " : " "}the g train ${fucked ? "is" : "isn’t"} ${howFucked}`;
return new Response(
render(
<html class="dark:bg-zinc-800 dark:text-white min-h-screen">
<head>
<title>{title}</title>
<meta
property="og:title"
content={`${title} as of ${
new Date(parsedTimestamp).toLocaleString("en-US", {
timeZone: "America/New_York",
})
}`}
/>
<meta
property="og:description"
content={`${entities.length} active alert${!fucked || soFucked ? "s" : ""}`}
/>
<meta
property="og:image"
content={fucked
? "https://pbt-gtrainog.web.val.run/?status=notOk"
: "https://pbt-gtrainog.web.val.run/?status=ok"}
/>
<meta property="og:url" content="www.isthegtrainfucked.com" />
<meta name="viewport" content="widthdevice-width, initial-scale=1.0" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="min-h-screen flex flex-col justify-center items-center gap-4">
<header class="italic text-4xl mb-6">
{uwu ? "UwU!" : ""} the g train {fucked
? (
<span>
is{" "}
<strong>
{soFucked ? (uwu ? "so fucky-wucky" : "so fucked") : (uwu ? "fucky-wucky" : "fucked")}{" "}
{uwu ? "(˶˃ᆺ˂˶)" : ""}
</strong>
</span>
)
: <span>isn’t {uwu ? "fucky-wucky" : "fucked"} {uwu ? "⸜(。 ˃ ᵕ ˂ )⸝♡" : ""}</span>}
</header>
<h1
style="background: #6CBE45"
class={`${
uwu ? "text-7xl" : "text-9xl"
} font-bold text-white rounded-full p-10 h-64 w-64 flex flex-col justify-center items-center`}
>
{fucked ? (uwu ? "• ᴖ •。" : "💩") : (uwu ? "👉👈" : ":)")}
</h1>
<main class="bg-slate-100 dark:bg-stone-900 p-10 m-10 rounded">
{fucked
? (
<div>
<h2 class="font-bold pb-2">
{uwu ? uwuifier.uwuifyWords("how it’s fucked as of") : "how it’s fucked as of"}{" "}
{new Date(parsedTimestamp).toLocaleString("en-US", {
timeZone: "America/New_York",
})}:
</h2>
<ul>
{entities.map(({ alert }) => {
const { text: active } = (alert["transit_realtime.mercury_alert"]["human_readable_active_period"]
?? { translation: [{ language: "en", text: "right now" }] }).translation.find((
{ language },
) => language === "en");
const { text } = alert.header_text.translation.find(({ language }) => language === "en-html");
return (
<li>
<div dangerouslySetInnerHTML={{ __html: uwu ? uwuifier.uwuifySentence(text) : text }} />
<p class="text-xs pt-1 pb-3">{uwu ? uwuifier.uwuifySentence(active) : active}</p>
</li>
);
})}
</ul>
<p>
<a target="__blank" class="underline" href="https://new.mta.info/">
{uwu ? uwuifier.uwuifySentence("alerts on mta.info") : "alerts on mta.info"}
</a>
</p>
</div>
)
: (
<span class="font-bold">
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.