From 7c9151e69311f584e6c11bc78f4ed6a466cc60ed Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Thu, 11 Jan 2024 18:43:30 +0000 Subject: [PATCH] Fix main page emojis --- index.js | 7 ++++++- static/discord/index.html | 43 +++++++++++++++++++++++++++++++++++++++ static/discord/index.js | 26 +++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 static/discord/index.html create mode 100644 static/discord/index.js diff --git a/index.js b/index.js index 12c3b62..31b9ce9 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,12 @@ function pageUpdate() { var status = lanyardData.activities[0] addedHTML += "

" if (status.emoji) { - addedHTML += ` ` + if (status.emoji.id) { + addedHTML += ` ` + } else { + addedHTML += status.emoji.name + } + } if (status.state) { addedHTML += `"` diff --git a/static/discord/index.html b/static/discord/index.html new file mode 100644 index 0000000..549639b --- /dev/null +++ b/static/discord/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + Discord Status - Violet's Purgatory + + + +

Sorry! This page requires javascript... The rest of this site doesn't, though!

+

Discord Status

+

This is a more fleshed out version of the main discord status on my site, issue being, it requires Javascript. So, I choose not to use it, though it coulda been cool...

+

I still am tempted to add something like it to the main page, and just make it compatible without javascript, but I worry that'd upset people.

+ +
+

Violet

+
+ +
+

They/Them

+

Developer

+

Offline

+
+
+
+

+
+
+ + + \ No newline at end of file diff --git a/static/discord/index.js b/static/discord/index.js new file mode 100644 index 0000000..3b9780a --- /dev/null +++ b/static/discord/index.js @@ -0,0 +1,26 @@ +var lanyard = new WebSocket('wss://api.lanyard.rest/socket') + +function beat(dur) { + lanyard.send(JSON.stringify({ + op: 3 + })) + setTimeout(() => { + beat(dur) + }, dur); +} + +lanyard.addEventListener("message", (res) => { + var data = JSON.parse(res.data) + if (data.op == 1) { + beat(data.d.heartbeat_interval) + lanyard.send(JSON.stringify({ + op: 2, + d: { + subscribe_to_id: "534132311781015564" + } + })) + } else if (data.op == 0) { + var lanyardData = data.d + $("*").text(JSON.stringify(lanyardData)) + } +}) \ No newline at end of file