Created
October 27, 2024 18:20
-
-
Save Firebladedoge229/6a59ad581f640e55ffe01479c7868a6c to your computer and use it in GitHub Desktop.
Quick script I wrote to find your position in ROBLOX's The Haunt avatar contest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const axios = (await import("axios")).default; | |
const chalk = (await import("chalk")).default; | |
async function getAuthenticatedUser(cookie) { | |
const url = "https://users.roblox.com/v1/users/authenticated"; | |
try { | |
const response = await axios.get(url, { | |
headers: { | |
"Cookie": `.ROBLOSECURITY=${cookie}` | |
} | |
}); | |
return response.data.id; | |
} catch (error) { | |
throw new Error(`Failed to authenticate user: ${error.message}`); | |
} | |
} | |
async function checkUserPosts(userId, category, cookie) { | |
const url = `https://apis.roblox.com/posts-api/v1/content-posts/findByUser?userId=${userId}&postTypeFilter=${category}`; | |
try { | |
const response = await axios.get(url, { | |
headers: { | |
"Cookie": `.ROBLOSECURITY=${cookie}` | |
} | |
}); | |
return response.data; | |
} catch (error) { | |
throw new Error(`Failed to fetch user posts: ${error.message}`); | |
} | |
} | |
function interpretPlacement(placement) { | |
switch (placement) { | |
case 4: | |
return chalk.redBright("No Votes"); | |
case 3: | |
return `Bottom ${chalk.redBright("50%")}`; | |
case 2: | |
return `Top ${chalk.hex("#34eb8f")("50%")}`; | |
case 1: | |
return `Top ${chalk.hex("#34eb8f")("10%")}`; | |
case 0: | |
return "Leaderboard"; | |
default: | |
return chalk.redBright("Unknown Placement"); | |
} | |
} | |
const readline = require("readline").createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
readline.question(chalk.hex("#34eb8f")("ROBLOSECURITY Cookie: "), async (cookie) => { | |
readline.question(chalk.hex("#34eb8f")("Category: "), async (category) => { | |
readline.question(chalk.hex("#34eb8f")("Interval: "), async (interval) => { | |
interval = parseInt(interval) * 1000; | |
try { | |
const userId = await getAuthenticatedUser(cookie.trim()); | |
console.log(chalk.hex("#34eb8f")(`Authenticated!`) + " User Id: " + chalk.hex("#34eb8f")(userId)); | |
setInterval(async () => { | |
try { | |
const postsData = await checkUserPosts(userId, category, cookie.trim()); | |
const posts = postsData.posts || []; | |
if (posts.length === 0) { | |
console.log(chalk.redBright("No posts found for the specified category.")); | |
} else { | |
posts.forEach(post => { | |
const placement = post.placement; | |
const placementStatus = interpretPlacement(placement); | |
console.log(chalk.hex("#34eb8f")("Placement: ") + placementStatus); | |
if (placement === 0 && post.top) { | |
console.log(chalk.hex("#34eb8f")("Leaderboard Rank: ") + post.top); | |
} | |
}); | |
} | |
} catch (error) { | |
console.log(chalk.redBright("Error fetching posts: ") + error.message); | |
} | |
}, interval); | |
} catch (error) { | |
console.log(chalk.redBright("Authentication Error: ") + error.message); | |
} | |
readline.close(); | |
}); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python version is located here
In order to run this script, you need to install the prerequisites by running: