From 9b71b06bce4d102379528e8b18545526a1bc1589 Mon Sep 17 00:00:00 2001 From: Bingus_Violet Date: Fri, 17 Nov 2023 14:43:11 +0000 Subject: [PATCH] bwah --- .gitignore | 2 +- index.js | 41 +++++++++++++++-------------------------- resources/mainPage.html | 6 +++--- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 8327e4c..e6fd96a 100644 --- a/.gitignore +++ b/.gitignore @@ -131,4 +131,4 @@ dist .pnp.* # Violet's Purgatory -static/assets/ \ No newline at end of file +static/index.html \ No newline at end of file diff --git a/index.js b/index.js index 9d78b50..048f3f9 100644 --- a/index.js +++ b/index.js @@ -21,10 +21,7 @@ app.listen(PORT, () => { console.log("Violet's Purgatory is now listening on port: " + PORT) }) -app.get("/", (req, res) => { - - res.setHeader("X-Content-Type-Options", "none") - +function pageUpdate() { var statuses = { "online": { "text": "Online", @@ -45,43 +42,34 @@ app.get("/", (req, res) => { } var html = fs.readFileSync(mainpage).toString() - - var checkpoint = ["{LANYARD_STATUS}", "{LANYARD}"] - function io(numb, end=false) { - if (end) { - return html.indexOf(checkpoint[numb]) + checkpoint[numb].length - } - return html.indexOf(checkpoint[numb]) - } - - res.write(html.substring(0, io(0))) + var addedHTML = "" var statusData = statuses[lanyardData.discord_status] - res.write(`

${statusData.text}

`) - res.write(``) + addedHTML += `

${statusData.text}

` + addedHTML += `` - res.write(html.substring(io(0, true), io(1))) + html = html.replace("{LANYARD_STATUS}", addedHTML) + + addedHTML = "" if (lanyardData) { for (let index = 0; index < lanyardData.activities.length; index++) { const activity = lanyardData.activities[index]; console.log(activity) if (activity.type == 2) { - res.write(`

Listening on ${activity.name}: ${activity.details} (by ${activity.state})

`) + addedHTML += `

Listening on ${activity.name}: ${activity.details} (by ${activity.state})

` } else if (activity.type == 4) { - res.write(`

"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}

`) + addedHTML += `

"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}

` } } - - console.log(lanyardData.activities) } - console.log(io(checkpoint.length - 1, true)) - res.write(html.substring(io(checkpoint.length - 1, true), html.length) + "

Thank you for checking out my website <3

", () => { - res.end() - }) -}) + + html = html.replace("{LANYARD}", addedHTML) + + fs.writeFileSync(path.join(__dirname, 'static/index.html'), html) +} // Lanyard Stuffs @@ -108,6 +96,7 @@ lanyard.addEventListener("message", (res) => { })) } else if (data.op == 0) { lanyardData = data.d + pageUpdate() } else { console.log(data.d) } diff --git a/resources/mainPage.html b/resources/mainPage.html index 31aa2b1..a269d76 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -5,12 +5,12 @@ - - + + Violet's Purgatory - +