Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let url = "https://catalog.roblox.com/v1/search/items?category=&CreatorName=ROBLOX&limit=120&maxPrice=0&minPrice=0&salesTypeFilter=1",
- purchaseUrl = "https://economy.roblox.com/v1/purchases/products/",
- detailsUrl = "https://catalog.roblox.com/v1/catalog/items/details",
- inventoryUrl = "https://inventory.roblox.com/v1/users/",
- csrfUrl = "https://economy.roblox.com/v1/purchases/products/666",
- userUrl = "https://users.roblox.com/v1/users/authenticated",
- welcomeMessageDisplayed = !1;
- async function getAuthenticatedUserInfo() {
- try {
- const e = await fetch(userUrl, {
- method: "GET",
- credentials: "include"
- });
- return await e.json()
- } catch (e) {
- throw new Error("Failed to fetch authenticated user information")
- }
- }
- async function getCSRFTokenFromUrl() {
- return new Promise((async (e, t) => {
- console.log("Generating CSRF Token...");
- try {
- const o = (await fetch(csrfUrl, {
- method: "POST",
- credentials: "include"
- })).headers.get("X-Csrf-Token");
- o ? e(o) : t(new Error("CSRF token not found in request response..."))
- } catch (e) {
- t(e)
- }
- }))
- }
- function delay(e) {
- return new Promise((t => setTimeout(t, e)))
- }
- async function fetchData(e) {
- const t = await fetch(e, {
- credentials: "include"
- }),
- o = await t.json(),
- a = o.nextPageCursor,
- s = o.data;
- let n = await getCSRFTokenFromUrl(),
- r = await getAuthenticatedUserInfo();
- const l = r.id,
- i = r.name,
- c = r.displayName,
- d = "";
- welcomeMessageDisplayed || (i.toLowerCase() !== c.toLowerCase() ? console.log(`Welcome to ${d}, ${i} A.K.A. ${c}!`) : console.log(`Welcome to ${d}, ${i}!`), welcomeMessageDisplayed = !0);
- const u = s.map((e => ({
- id: e.id,
- itemType: "Asset" === e.itemType ? 1 : 2
- }))),
- m = await fetch(detailsUrl, {
- method: "POST",
- body: JSON.stringify({
- items: u
- }),
- headers: {
- "Content-Type": "application/json",
- "X-Csrf-Token": n
- },
- credentials: "include"
- }),
- h = (await m.json()).data;
- for (let e = 0; e < h.length; e++) {
- const t = h[e],
- o = t.id.toString(),
- a = t.name,
- s = "Bundle" === t.itemType ? 3 : 0;
- let r, i;
- do {
- if (r = await fetch(`${inventoryUrl}${l}/items/${s}/${o}`), i = await r.json(), 429 === r.status) {
- const e = Math.floor(3e4 * Math.random()) + 3e4;
- console.log(`Too many requests. Waiting for ${e/1e3} seconds...`), await delay(e)
- }
- } while (429 === r.status);
- if (null === i.nextPageCursor && null === i.previousPageCursor && 0 === i.data.length) {
- const s = JSON.stringify({
- expectedCurrency: 1,
- expectedPrice: 0,
- expectedSellerId: 1
- });
- let r, l;
- 0 === e || await delay(Math.floor(0 * Math.random()) + 500), console.log(`Attempting to buy item "${a}" (#${e+1} out of ${h.length})`);
- do {
- if (r && 429 === r.status || l && l.errors && 27 === l.errors[0].code) {
- const e = Math.floor(3e4 * Math.random()) + 3e4;
- console.log(`Too many requests. Waiting for ${e/1e3} seconds...`), await delay(e)
- }
- r && "Token Validation Failed" == l.message && (console.log("Token validation failed. Generating a new CSRF Token..."), n = await getCSRFTokenFromUrl()), r = await fetch(purchaseUrl + t.productId, {
- method: "POST",
- body: s,
- headers: {
- "Content-Type": "application/json",
- "X-Csrf-Token": n
- },
- credentials: "include"
- }), l = await r.json()
- } while (429 === r.status || 403 === r.status);
- l.purchased ? (console.log(`Purchase successful for item "${a}" (ID: ${o})`), console.log(l)) : "AlreadyOwned" === l.reason ? console.log(`Item "${a}" (ID: ${o}) is already owned`) : (console.log(`Purchase failed for item "${a}" (ID: ${o})`), console.log(l))
- } else console.log(`Skipping owned item "${a}" (ID: ${o}) (#${e+1} out of ${h.length})`)
- }
- if (null !== a) {
- const t = e.replace(/&cursor=.*/, "") + `&cursor=${a}`;
- await fetchData(t)
- }
- }
- fetchData(url);
- console.log("\n < Completely Loaded. > \n < Free item hunter [Only roblox items version] > \n < V1.0 > \n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement