This commit is contained in:
Bingus_Violet 2023-11-17 14:43:11 +00:00
parent 38a1870b0e
commit 9b71b06bce
3 changed files with 19 additions and 30 deletions

2
.gitignore vendored
View file

@ -131,4 +131,4 @@ dist
.pnp.* .pnp.*
# Violet's Purgatory # Violet's Purgatory
static/assets/ static/index.html

View file

@ -21,10 +21,7 @@ app.listen(PORT, () => {
console.log("Violet's Purgatory is now listening on port: " + PORT) console.log("Violet's Purgatory is now listening on port: " + PORT)
}) })
app.get("/", (req, res) => { function pageUpdate() {
res.setHeader("X-Content-Type-Options", "none")
var statuses = { var statuses = {
"online": { "online": {
"text": "Online", "text": "Online",
@ -46,42 +43,33 @@ app.get("/", (req, res) => {
var html = fs.readFileSync(mainpage).toString() var html = fs.readFileSync(mainpage).toString()
var checkpoint = ["{LANYARD_STATUS}", "{LANYARD}"] var addedHTML = ""
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 statusData = statuses[lanyardData.discord_status] var statusData = statuses[lanyardData.discord_status]
res.write(`<p style="color: ${statusData.color}">${statusData.text}</p>`) addedHTML += `<p style="color: ${statusData.color}">${statusData.text}</p>`
res.write(`<style>.pfp { border-color: ${statusData.color} !important }</style>`) addedHTML += `<style>.pfp { border-color: ${statusData.color} !important }</style>`
res.write(html.substring(io(0, true), io(1))) html = html.replace("{LANYARD_STATUS}", addedHTML)
addedHTML = ""
if (lanyardData) { if (lanyardData) {
for (let index = 0; index < lanyardData.activities.length; index++) { for (let index = 0; index < lanyardData.activities.length; index++) {
const activity = lanyardData.activities[index]; const activity = lanyardData.activities[index];
console.log(activity) console.log(activity)
if (activity.type == 2) { if (activity.type == 2) {
res.write(`<p class="chip">Listening on <a style="color: limegreen">${activity.name}</a>: ${activity.details} (by ${activity.state})</p>`) addedHTML += `<p class="chip">Listening on <a style="color: limegreen">${activity.name}</a>: ${activity.details} (by ${activity.state})</p>`
} else if (activity.type == 4) { } else if (activity.type == 4) {
res.write(`<p><em><span style="color: lightgray">"${lanyardData.activities[0].state}"</span> - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}</em></p>`) addedHTML += `<p><em><span style="color: lightgray">"${lanyardData.activities[0].state}"</span> - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}</em></p>`
} }
} }
console.log(lanyardData.activities)
} }
console.log(io(checkpoint.length - 1, true))
res.write(html.substring(io(checkpoint.length - 1, true), html.length) + "<p>Thank you for checking out my website <3</p>", () => { html = html.replace("{LANYARD}", addedHTML)
res.end()
}) fs.writeFileSync(path.join(__dirname, 'static/index.html'), html)
}) }
// Lanyard Stuffs // Lanyard Stuffs
@ -108,6 +96,7 @@ lanyard.addEventListener("message", (res) => {
})) }))
} else if (data.op == 0) { } else if (data.op == 0) {
lanyardData = data.d lanyardData = data.d
pageUpdate()
} else { } else {
console.log(data.d) console.log(data.d)
} }

View file

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/bootstrap.min.css"> <link rel="stylesheet" href="./bootstrap.min.css">
<link rel="stylesheet" href="/style.css"> <link rel="stylesheet" href="./style.css">
<title>Violet's Purgatory</title> <title>Violet's Purgatory</title>
<link href="/Rubik/Rubik-VariableFont_wght.ttf"> <link href="./Rubik/Rubik-VariableFont_wght.ttf">
<meta content="Welcome to Violet's Purgatory" property="og:title" /> <meta content="Welcome to Violet's Purgatory" property="og:title" />
<meta <meta