Download index.js from KatHub/README: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/spaces/KatHub/README/resolve/main/index.js
- Command line
-
hf download hf://spaces/KatHub/README/index.js
-
curl -L -o index.js https://huggingface.co/spaces/KatHub/README/resolve/main/index.js
4.14 kB
| import express from "express"; | |
| import fetch from "node-fetch"; | |
| const app = express(); | |
| const PORT = process.env.PORT || 5000; | |
| // The Auth Token is now embedded directly into the URL query parameters | |
| const AUTH_TOKEN = "AIzaSyBokCjJ7bIUOk_beo2gWQXst6PKqlFFEpc"; | |
| const API_URL = `https://yalohsosipisky-default-rtdb.firebaseio.com/servers.json?auth=${AUTH_TOKEN}`; | |
| const DISCORD_WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL; | |
| const REFRESH_RATE = 2000; | |
| const PLACE_ID = "109983668079237"; | |
| let jobData = []; | |
| let sentJobIds = new Set(); | |
| let isSending = false; | |
| app.get("/", (req, res) => { | |
| const html = ` | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Job IDs</title> | |
| <meta http-equiv="refresh" content="2"> | |
| <style> | |
| body { font-family: monospace; background: #1a1a1a; color: #0f0; padding: 20px; } | |
| h1 { color: #0f0; } | |
| .job-id { padding: 5px 0; font-size: 16px; border-bottom: 1px solid #333; } | |
| a { color: #0f0; text-decoration: none; font-weight: bold; } | |
| a:hover { color: #fff; } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Job IDs (Authenticated)</h1> | |
| ${jobData.length > 0 | |
| ? jobData.map(job => `<div class="job-id">${job.name} - ${job.money}/s - <a href="${job.link}" target="_blank">JOIN LINK</a></div>`).join('') | |
| : '<p>Waiting for data from Firebase...</p>'} | |
| </body> | |
| </html> | |
| `; | |
| res.send(html); | |
| }); | |
| app.get("/jobids", (req, res) => { | |
| res.json(jobData); | |
| }); | |
| async function sendToDiscord(newJobs) { | |
| if (!DISCORD_WEBHOOK_URL || newJobs.length === 0 || isSending) return; | |
| isSending = true; | |
| for (const job of newJobs) { | |
| if (sentJobIds.has(job.jobId)) continue; | |
| sentJobIds.add(job.jobId); | |
| try { | |
| const message = { | |
| embeds: [{ | |
| title: "π NEW SERVER FOUND", | |
| color: 0x783cc4, // Purple color to match your UI | |
| fields: [ | |
| { name: "π Name", value: job.name, inline: true }, | |
| { name: "𧬠Mutation", value: job.mutation, inline: true }, | |
| { name: "π° Money/Sec", value: `${job.money}`, inline: true }, | |
| { name: "πΎ Tier", value: job.tier, inline: true }, | |
| { name: "π Job ID", value: `\`${job.jobId}\``, inline: false }, | |
| { name: "π Join Link", value: `[Click to Join](https://www.roblox.com/games/${PLACE_ID}/?gameInstanceId=${job.jobId})`, inline: false } | |
| ], | |
| timestamp: new Date() | |
| }] | |
| }; | |
| await fetch(DISCORD_WEBHOOK_URL, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(message) | |
| }); | |
| console.log(`β Notified Discord: ${job.name}`); | |
| await new Promise(r => setTimeout(r, 1000)); // Prevent Discord rate limit | |
| } catch (err) { | |
| console.error("Discord Error:", err.message); | |
| } | |
| } | |
| isSending = false; | |
| } | |
| async function fetchJobIds() { | |
| try { | |
| const response = await fetch(API_URL); | |
| const data = await response.json(); | |
| if (data && typeof data === 'object') { | |
| const formattedJobs = []; | |
| // Firebase returns an object of objects, so we iterate through keys | |
| for (const key in data) { | |
| const server = data[key]; | |
| const jobId = server.jobId || key; | |
| formattedJobs.push({ | |
| name: server.name || "Unknown", | |
| mutation: server.isBrainrot ? "Brainrot" : "Normal", | |
| money: server.moneyPerSec || "0", | |
| tier: (server.name === "Strawberry Elephant" || server.name === "Meowl") ? "OG TIER" : "Secret", | |
| jobId: jobId, | |
| link: `https://www.roblox.com/games/${PLACE_ID}/?gameInstanceId=${jobId}` | |
| }); | |
| } | |
| jobData = formattedJobs; | |
| const newJobs = jobData.filter(job => !sentJobIds.has(job.jobId)); | |
| if (newJobs.length > 0) { | |
| sendToDiscord(newJobs); | |
| } | |
| } | |
| } catch (err) { | |
| console.error("Firebase Fetch Error:", err.message); | |
| } | |
| } | |
| // Initial fetch and start interval | |
| fetchJobIds(); | |
| setInterval(fetchJobIds, REFRESH_RATE); | |
| app.listen(PORT, "0.0.0.0", () => { | |
| console.log(`Server is live on port ${PORT}`); | |
| }); |