From 69f8f741821da949277ad181698fa860050ab701 Mon Sep 17 00:00:00 2001 From: wont-stream <143244075+wont-stream@users.noreply.github.com> Date: Tue, 8 Apr 2025 06:42:30 -0400 Subject: [PATCH] Refactor WebSocket integration and move JavaScript from index.ts to index.js --- src/index.html | 110 ++++++++++++++++++++++++++++++++++++- src/{index.ts => index.js} | 18 +++--- 2 files changed, 116 insertions(+), 12 deletions(-) rename src/{index.ts => index.js} (85%) diff --git a/src/index.html b/src/index.html index dd3c570..5159c7d 100644 --- a/src/index.html +++ b/src/index.html @@ -27,7 +27,8 @@
- pfp + pfp

Seth

A backend developer.

@@ -57,7 +58,112 @@
- + \ No newline at end of file diff --git a/src/index.ts b/src/index.js similarity index 85% rename from src/index.ts rename to src/index.js index 9f065e3..e26d73d 100644 --- a/src/index.ts +++ b/src/index.js @@ -2,13 +2,6 @@ const pfp = document.getElementById("pfp"); const music = document.getElementById("music"); const heartrate = document.getElementById("heartrate"); -const presenceMap = { - "online": "border-success-subtle", - "idle": "border-warning-subtle", - "dnd": "border-danger-subtle", - "offline": "border-light-subtle" -} - const lanyard = new WebSocket("wss://lanyard.creations.works/socket"); lanyard.onopen = () => { @@ -25,9 +18,14 @@ lanyard.onmessage = ({ data }) => { switch (op) { case 0: { - pfp.className = `border border-4 rounded-circle ${presenceMap[d.discord_status]}` + pfp.className = `border border-4 rounded-circle ${{ + "online": "border-success-subtle", + "idle": "border-warning-subtle", + "dnd": "border-danger-subtle", + "offline": "border-light-subtle" + }[d.discord_status]}` - const tidalData = d.activities.filter((act: Activities) => { + const tidalData = d.activities.filter((act) => { return act?.application_id === "1130698654987067493"; })[0]; @@ -57,7 +55,7 @@ const hyperate = new WebSocket( "wss://app.hyperate.io/socket/websocket?token=wv39nM6iyrNJulvpmMQrimYPIXy2dVrYRjkuHpbRapKT2VSh65ngDGHdCdCtmEN9", ); -let hrTimeout: ReturnType; +let hrTimeout; const setHrInterval = async () => { hrTimeout = setTimeout(async () => {