Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
dc89117
Merge pull request #13 from TheTrueShaman/main
DespicableGoose May 9, 2024
6ad3846
Update API to v2
DespicableGoose May 9, 2024
0b28964
Update API to v2
DespicableGoose May 9, 2024
04718a6
Update calculate.js
DespicableGoose May 9, 2024
ee5b7a5
Making price-finder's auction house data fetching logic
DespicableGoose May 9, 2024
86bb94f
Update calculate.js
DespicableGoose May 9, 2024
3fa61b6
Create nbt.js
DespicableGoose May 9, 2024
9349f6c
Update index.html
DespicableGoose May 9, 2024
e878e4d
Update calculate.js
DespicableGoose May 9, 2024
534a498
Update calculate.js
DespicableGoose May 9, 2024
29c0966
Update calculate.js
DespicableGoose May 9, 2024
25fa52f
Update calculate.js
DespicableGoose May 9, 2024
1286da4
Update calculate.js
DespicableGoose May 9, 2024
52128a0
Deleting price-finder
DespicableGoose May 9, 2024
2950d33
Update index.html
DespicableGoose May 9, 2024
f517dcb
Recreating project
DespicableGoose May 9, 2024
ac3a6cc
Recreating project
DespicableGoose May 9, 2024
1c20db4
Recreating project
DespicableGoose May 9, 2024
dd7e338
Recreating project
DespicableGoose May 9, 2024
952cdcb
Update calculate.js
DespicableGoose May 10, 2024
ed0c13a
Update calculate.js
DespicableGoose May 10, 2024
6835f4a
Fixed getting max bin instead of min bin
DespicableGoose May 10, 2024
9925ee6
Update calculate.js
DespicableGoose May 10, 2024
4d5d442
Update calculate.js
DespicableGoose May 10, 2024
59ab1fb
Update calculate.js
DespicableGoose May 10, 2024
dc4024c
Update calculate.js
DespicableGoose May 10, 2024
c059993
Update index.html
DespicableGoose May 10, 2024
d67e5ac
Update index.html
DespicableGoose May 10, 2024
6beb804
Update calculate.js
DespicableGoose May 10, 2024
c66fad1
Update index.html
DespicableGoose May 10, 2024
5c602bc
Update calculate.js
DespicableGoose May 10, 2024
a33777a
Update calculate.js
DespicableGoose May 10, 2024
10a9aa9
Update index.html
DespicableGoose May 10, 2024
82ff7d5
Update calculate.js
DespicableGoose May 10, 2024
afe238e
Update calculate.js
DespicableGoose May 10, 2024
acd1ef5
Update calculate.js
DespicableGoose May 10, 2024
f796869
Update calculate.js
DespicableGoose May 10, 2024
3d2c0af
Update calculate.js
DespicableGoose May 10, 2024
2ae1b00
Update calculate.js
DespicableGoose May 10, 2024
ea32e24
Update calculate.js
DespicableGoose May 11, 2024
106bd9c
Update calculate.js
DespicableGoose May 11, 2024
61e91ab
Update calculate.js
DespicableGoose May 11, 2024
110d843
Update calculate.js
DespicableGoose May 11, 2024
ec694c8
Update calculate.js
DespicableGoose May 11, 2024
274faab
Update calculate.js
DespicableGoose May 11, 2024
ef6fb6c
Update calculate.js
DespicableGoose May 11, 2024
efc3b35
Update index.html
DespicableGoose May 11, 2024
379f1a7
Update index.html
DespicableGoose May 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auctions-viewer/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getAuctions(type) {
}

async function getPage(page) {
let auctionsURL = new URL('https://api.hypixel.net/skyblock/auctions')
let auctionsURL = new URL('https://api.hypixel.net/v2/skyblock/auctions')
auctionsURL.searchParams.set('page', page);
const auctionPageData = await fetch(auctionsURL);
const auctionPageJSON = await auctionPageData.json();
Expand Down
166 changes: 165 additions & 1 deletion price-finder/calculate.js
Original file line number Diff line number Diff line change
@@ -1 +1,165 @@
//https://moulberry.codes/lowestbin.json
async function getAuctions(type) {
let auctionsList = [];
auctionsList.push(await getAuctionsPage(0));
let pages = auctionsList[0]['totalPages']
for (let i = 1; i < pages; i++) {
auctionsList.push(await getAuctionsPage(i));
}

let binList = [];
let item;
for (let a = 0; a < auctionsList.length; a++) {
for (let b = 0; b < auctionsList[a]['auctions'].length; b++) {
item = auctionsList[a]['auctions'][b];
if (item['bin'] === false || item['claimed'] === true) {
continue;
}

let bytes = convertNbtToJson(item['item_bytes'])
if (!bytes) {
continue;
}

binList.push({ id: bytes[0].tag.ExtraAttributes.id, name: item['item_name'], price: item['starting_bid'], rarity: item['tier']});
}
}

let itemPriceList = {}

for (let i = 0; i < binList.length; i++) {
item = binList[i];
if (itemPriceList[item['id']]) {
if (item.price > itemPriceList[item['id']].price) {
continue;
}

if (item.id === 'PET') {
// Pets are not currently supported
continue;
}
}

itemPriceList[item['id']] = {name: item['name'], price: item['price']};
}

return itemPriceList;
}

async function getAuctionsPage(page) {
let auctionsURL = new URL('https://api.hypixel.net/v2/skyblock/auctions')
auctionsURL.searchParams.set('page', page);
const auctionPageData = await fetch(auctionsURL);
const auctionPageJSON = await auctionPageData.json();
console.log(auctionPageJSON);
return auctionPageJSON;
}

async function getBazaar() {
const bazaarData = await fetch('https://api.hypixel.net/v2/skyblock/bazaar');
const bazaarJSON = await bazaarData.json();

let bazaarList = {};
let product;
for (productKey in bazaarJSON['products']) {
product = bazaarJSON['products'][productKey];
bazaarList[product['quick_status']['productId']] = {price: product['quick_status']['buyPrice']};
}

return bazaarList;
}

async function getItems() {
const itemsData = await fetch('https://api.hypixel.net/v2/resources/skyblock/items');
const itemJSON = await itemsData.json();

let itemList = {};
let item;
for (let i = 0; i < itemJSON.items.length; i++) {
item = itemJSON['items'][i];
itemList[item['name']] = item['id'];
}

return itemList;
}

async function loadAll() {
let finalTable = {};
let auctionsList = await getAuctions();
Object.assign(finalTable, auctionsList);
let bazaarList = await getBazaar();
Object.assign(finalTable, bazaarList);
let nameToId = await getItems();

window.finalTable = finalTable;
window.nameToId = nameToId;
document.getElementById("warning").style.display = "none";
console.log(finalTable);
}

loadAll();

function search() {
if (!window.finalTable) {
return;
}

window.search_input = document.getElementById("search_bar").value;
if (window.search_input != '') {
const searchItems = window.search_input.split('; ');
const regex = /^((\d+?)x)? ?(.+)$/;
let costs = {};
for (let i = 0; i < searchItems.length; i++) {
let inputName = searchItems[i];
let found = inputName.match(regex);
let mult = 1;
if (found[2]) {
mult = parseInt(found[2]);
}
let itemName = found[3];

if (!window.finalTable[itemName] && !window.nameToId[itemName]) {
console.warn("No price found for: " + itemName);
continue;
}

if (window.nameToId[itemName]) {
if (!window.finalTable[window.nameToId[itemName]]) {
console.warn("No price found for: " + itemName);
continue;
}

itemName = window.nameToId[itemName];
}

costs[inputName] = Math.round(1000 * window.finalTable[itemName].price * mult) / 1000; // Round to 3 decimal places
}
displayResults(costs);
} else {
document.getElementById('main').innerHTML = '';
}
}

function displayResults(results) {
let html = '<table><tr><th>Item</th><th>Cost</th></tr>';
let sum = 0;
console.log(results);
for (result in results) {
sum += results[result];
html += '<tr><td>' + result + '</td><td>' + results[result] + ' </td></tr>';
}
html += '<tr><td>Total</td><td>' + sum + ' </td></tr></table>';
document.getElementById('main').innerHTML = html;
return;
}


function convertNbtToJson(t) {
let data;
try {
const n=Uint8Array.from(atob(t),t=>t.charCodeAt(0)),a=new Zlib.Gunzip(n).decompress();
nbt.parse(a,function(t,n){if(t)throw t;data=n})
} catch(t) {
console.log("Invalid input: couldn't parse nbt data");
}
return data;
}
28 changes: 25 additions & 3 deletions price-finder/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Skyblock Profile Viewer</title>
<title>Skyblock Price Calculator</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
Expand Down Expand Up @@ -31,17 +31,39 @@
input:valid {
border: 2px solid black;
}

table {
border-collapse: collapse;
}

td, th {
border: 1px solid #000000;
text-align: left;
padding: 0.5em;
}
</style>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
</head>
<body>
<script src="nbt.js"></script>
<script src="calculate.js"></script>

<div class="header">
<h1>Skyblock Price Calculator</h1>
</div>

<div id="main"></div>
<br>
<div id="warning" style="display:block; text-align: center;">
<h3 style="color: darkred">The data is currently loading!</h3>
</div>

<div style="display:flex;">
<div id="search" style="display: flex; width:100%;">
<input type="text" id="search_bar" style="width:70%; display: inline-block; outline: none; margin-left:40px; margin-right:40px; font-size: 1.5em"><button style="width:20%; display: inline-block;" onclick="search()">Search</button>
</div>
</div>
<br>
<br>
<div id="main" style="margin:40px;"></div>

</body>
</html>
Loading