diff --git a/index.js b/index.js index 5eb4fa3..a1ba8ea 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,34 @@ var cachePath = path.join(staticpath, 'cached') var fontPath = path.join(staticpath, "fonts") app.use("/fonts", express.static(fontPath)) +app.use("/cached", express.static(cachePath)) + +app.get("/disc", (req, res) => { + var looping = true + + res.setHeader("X-Accel-Buffering", "no") + res.write(fs.readFileSync(path.join(__dirname, "resources/disc.html"))) + + var iterations = 0 + var lastAct = null + + function loop() { + var currentAct = pageUpdater.getActivities() + if (currentAct != lastAct) { + lastAct = currentAct + iterations += 1 + res.write(`
`) + res.write(currentAct.substring(currentAct.indexOf("`) + res.write(``) + } + setTimeout(() => { + loop() + res.write("") + }, 5000); + } + loop() +}) if (!fs.existsSync(cachePath)) { fs.mkdirSync(cachePath) diff --git a/overcomplicatedStatuses.js b/overcomplicatedStatuses.js index 0938991..96c44ec 100644 --- a/overcomplicatedStatuses.js +++ b/overcomplicatedStatuses.js @@ -80,7 +80,7 @@ module.exports = { } if (!debounce && activity.type != 4) { - addedHTML += `


What I'm up to:

` + addedHTML += `


What I'm up to:

Check it out in real time! (buggy & unoptimized)

` debounce = true } @@ -93,7 +93,7 @@ module.exports = { return 'imgs/notFound.png' } - return './cached/' + fn + return '/cached/' + fn } function songStats() { diff --git a/pageUpdater.js b/pageUpdater.js index 950be01..3cb0018 100644 --- a/pageUpdater.js +++ b/pageUpdater.js @@ -99,6 +99,10 @@ function converter(html, query) { } module.exports = { + getActivities: function () { + return activityToHTML.activitiesToHTML(lanyardData, cachedImages) + }, + middleWare: function (req, res, next) { var filePath = (req.baseUrl + req.path).trim() diff --git a/resources/disc.html b/resources/disc.html new file mode 100644 index 0000000..76821d1 --- /dev/null +++ b/resources/disc.html @@ -0,0 +1,20 @@ + + + + + + + + + + + Dynamic Disc Status + + +
+ +
+

Dynamicly Updating Discord Status

+

This page is basically the same as the one present on the site, but it updates in real time!

+


How does it work?

+

Its a little big buggy- Pretty much, it just keeps writing html to the client, and telling it the HTML never finished. Yeah. Not great. Very easily could cause a data leak i think? Idk, what do you think I am, a programmer????

\ No newline at end of file diff --git a/static/index.html b/static/index.html index ea26c33..d90878a 100644 --- a/static/index.html +++ b/static/index.html @@ -44,6 +44,7 @@

Make sure to check out this project on Codeberg!

+ {ACTIVITIES}


Services

diff --git a/static/subpage.css b/static/subpage.css index 11a651b..9bfb586 100644 --- a/static/subpage.css +++ b/static/subpage.css @@ -13,7 +13,7 @@ body { } main { - animation: fadeUp 2s cubic-bezier(0.075, 0.82, 0.165, 1); + animation: fadeUp 1s cubic-bezier(0.075, 0.82, 0.165, 1); } @keyframes fadeUp {