Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const fetch = require('node-fetch'); // comment this line out if you're running in the browser
- const fs = require('fs'); // comment this line out if you're running in the browser
- const base = `https://inventory.roblox.com/v1/assets`;
- const SAVE_TO_FILE = true;
- const SAVE_JSON = true;
- let options = {
- AssetID: 100425940,
- SortOrder: 'Asc',
- Limit: 100,
- Cursor: '',
- FindSerials: [1, 6, 23, 25],
- CountDeleted: true
- };
- function Get(assetid, cursor = '', sortOrder = 'Asc', limit = 10) {
- if (!assetid) {
- throw new Error('Include asset id');
- }
- if (sortOrder != 'Asc' && sortOrder != 'Desc' && sortOrder != '') {
- sortOrder = 'Asc';
- };
- if (limit != 10 && limit != 25 && limit != 50 && limit != 100 && limit != '') {
- limit = 10;
- };
- return new Promise((resolve, reject) => {
- let url = `${base}/${assetid}/owners/?sortOrder=${sortOrder}&limit=${limit}&cursor=${cursor}`;
- fetch(url)
- .then(res => res.json())
- .then(data => {
- resolve(data);
- })
- .catch(err => console.warn(err));
- });
- };
- let [SerialOwners, Owners, Total, TotalBC, TotalBanned] = [{}, [], 0, 0, 0];
- async function Run() {
- let data = await Get(options.AssetID, options.Cursor, options.SortOrder, options.Limit);
- for (let item of data.data) {
- let ownerData;
- if (item.owner) {
- Total += 1;
- ownerData = {
- Username: item.owner.username,
- ID: item.owner.userId,
- userAssetId: item.userAssetId,
- PurchaseTime: item.created,
- BC: item.owner.buildersClubMembershipType
- };
- if (item.owner.buildersClubMembershipType != 0) {
- TotalBC += 1;
- };
- } else {
- if (options.CountDeleted) {
- Total += 1;
- };
- TotalBanned += 1;
- ownerData = {
- Username: '[DELETED]',
- ID: '[DELETED]',
- userAssetId: item.userAssetId,
- PurchsaeTime: item.created
- };
- };
- if (item.serialNumber) {
- if (options.FindSerials.includes(item.serialNumber)) {
- SerialOwners[item.serialNumber] = ownerData;
- };
- };
- if (SAVE_JSON) {
- Owners.push(ownerData);
- };
- if (SAVE_TO_FILE) {
- // comment out the below section if you are running in the browser
- if (item.owner) {
- fs.appendFileSync(`${options.AssetID}.txt`, `${item.owner.userId} - ${item.owner.username}\r\n`);
- } else if (options.CountDeleted) {
- fs.appendFileSync(`${options.AssetID}.txt`, `[DELETED] - [DELETED]\r\n`);
- };
- };
- };
- if (data.nextPageCursor != null && data.nextPageCursor != '') {
- options.Cursor = data.nextPageCursor;
- Run();
- } else {
- console.log(`Total Owners (including Roblox): ${Total}\nTotal BC Owners (including Roblox): ${TotalBC}\nTotal Deleted Owners: ${TotalBanned}\nTotal Without Deleted Owners (including Roblox): ${Total - TotalBanned}\nFound Serials:\n`, SerialOwners);
- // comment out the below section if you are running in the browser
- fs.appendFileSync(`${options.AssetID}.txt`, `Total Owners (including Roblox): ${Total}\nTotal BC Owners (including Roblox): ${TotalBC}\nTotal Deleted Owners: ${TotalBanned}\nTotal Without Deleted Owners (including Roblox): ${Total - TotalBanned}`);
- if (SAVE_JSON) {
- fs.writeFileSync(`${options.AssetID}.json`, JSON.stringify(Owners));
- };
- };
- };
- Run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement