-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
270 lines (216 loc) · 10.4 KB
/
main.js
File metadata and controls
270 lines (216 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
const REFORGES = ["Raggedy","Strengthened","Waxed","Fortunate","Excellent","Bustling","Honed","Hardened","Blooming","Glistening","NotSo","Dull","Hyper","Fair","Renowned","Loving","Gentle","Odd","Fast","Fair","Epic","Sharp","Heroic","Spicy","Legendary","Dirty","Fabled","Suspicious","Gilded","Warped","Withered","Bulky","Salty","Treacherous","Stiff","Lucky","Very","Highly","Extremely","Thicc","Absolutely","Even More", "Wise","Strong","Superior","Heavy","Light","Perfect","Refined","Deadly","Fine","Grand","Hasty","Neat","Rapid","Unreal","Awkward","Rich","Precise","Spiritual","Headstrong","Clean","Fierce","Mythic","Pure","Smart","Titanic","Necrotic","Ancient","Spiked","Cubic","Reinforced","Loving","Ridiculous","Empowered","Giant","Submerged","Jaded","Bizarre","Itchy","Ominous","Pleasant","Pretty","Shiny","Simple","Strange","Vivid","Godly","Demonic","Forceful","Hurtful","Keen","Strong","Unpleasant","Zealous","Silky","Bloody","Shaded","Sweet","Moil","Toil","Blessed","Bountiful","Magnetic","Fruitful","Refined","Stellar","Mithraic","Auspicious","Fleet","Heated","Ambered"]
const ALPHA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const API = "https://api.hypixel.net/skyblock/auctions?page=0"
const ITEMSAPI = "https://api.hypixel.net/resources/skyblock/items"
var itemTable = new Map()
numberSort = function (a,b) {
return a - b;
};
function createWidget(imageUrl, itemName, buyoutPrice, roofPrice, isRoof, real_name) {
const containerId = isRoof ? 'roof' : 'no-roof';
const container = document.getElementById(containerId);
const widget = document.createElement('div');
widget.classList.add('widget');
if (isRoof) {
widget.classList.add('roof');
}
const name = document.createElement('h3');
name.textContent = itemName;
widget.appendChild(name);
const imageContainer = document.createElement('div');
imageContainer.classList.add('image-container');
const imageL = document.createElement('a');
imageL.href = "./viewer.html?item="+real_name
imageL.target = "_blank"
const image = document.createElement('img');
image.src = imageUrl;
if (image.src.includes("png")){
imageContainer.classList.add("item");
}
imageContainer.appendChild(imageL);
imageL.appendChild(image)
widget.appendChild(imageContainer);
const priceContainer = document.createElement('div');
priceContainer.classList.add('price-container');
const buyoutLabel = document.createElement('p');
buyoutLabel.textContent = 'Buyout Price: ';
priceContainer.appendChild(buyoutLabel);
const buyout = document.createElement('span');
buyout.classList.add('price');
buyout.textContent = '$' + buyoutPrice.toLocaleString("en-US");;
buyoutLabel.appendChild(buyout);
if (isRoof) {
const roofPriceLabel = document.createElement('p');
roofPriceLabel.textContent = 'Roof Price: ';
priceContainer.appendChild(roofPriceLabel);
const roofPriceElement = document.createElement('span');
roofPriceElement.classList.add('price');
roofPriceElement.textContent = '$' + roofPrice.toLocaleString("en-US");;
roofPriceLabel.appendChild(roofPriceElement);
}
widget.appendChild(priceContainer);
container.appendChild(widget);
}
async function getItemTable(){
var resp = await fetch(ITEMSAPI);
var json = await resp.json()
json.items.forEach(async item => {
let real_name = ""
for (let char of item.name){
if (ALPHA.includes(char)) {
real_name += char;
}
}
REFORGES.forEach(reforge => {
real_name = real_name.replace(reforge, "")
})
var image_link = "./images/" + item.material.toLowerCase() + ".png"
if (item.material == "SKULL_ITEM"){
if (item.skin == undefined){
console.log(item)
} else{
var hash = JSON.parse(atob(item.skin)).textures.SKIN.url.split("/")
hash = hash[hash.length-1]
image_link = "https://nmsr.nickac.dev/headiso/" + hash
}
}
itemTable.set(real_name, {name : item.name, id : item.id, image : image_link})
})
}
async function getManips(MAX_ITEMS, MIN_ITEMS, MAX_BUY_IN, MIN_MULTI, MIN_FLAT, MAX_MIN_PRICE, MIN_MIN_PRICE, HIDE_NO_ROOF_MANIPS, HIDE_DUNGEON_ITEMS, HIDE_DRAGON_ITEMS, HIDE_PET_SKINS, HIDE_FURNITURE){
var resp = await fetch(API)
var json = await resp.json()
var pages = json.totalPages
var items = new Map()
var promises = []
for (let i = 0; i < pages; i++){
promises.push(new Promise(async (resolve, reject) => {
var response = await fetch(`https://api.hypixel.net/skyblock/auctions?page=${i}`)
var j = await response.json()
j.auctions.forEach(auction => {
if (!auction.bin) { }
else if (auction["item_lore"].toLowerCase().includes("furniture") && HIDE_FURNITURE) { }
else if (auction["item_lore"].toLowerCase().includes("pet skin") && HIDE_PET_SKINS) { }
else if (auction["item_name"].toLowerCase().includes("minion skin")) { }
else if (auction["item_name"].toLowerCase().includes("potion")) { }
else if (auction["item_lore"].toLowerCase().includes("cosmetic") && !auction["item_lore"].toLowerCase().includes("pet skin")) { }
else if (auction["item_name"].toLowerCase().includes("rune")) { }
else if (auction["item_lore"].toLowerCase().includes("dungeon") && HIDE_DUNGEON_ITEMS) { }
else if (auction["item_name"].toLowerCase().includes("dragon") && HIDE_DRAGON_ITEMS) { }
else {
let real_name = ""
for (let char of auction["item_name"]){
if (ALPHA.includes(char)) {
real_name += char;
}
}
REFORGES.forEach(reforge => {
real_name = real_name.replace(reforge, "")
})
if (real_name == "HurricaneBowx") {
real_name = "HurricaneBow"
}
if (!(items.has(real_name))){
items.set(real_name, [])
}
items.get(real_name).push(auction["starting_bid"])
}
});
console.log("Page loaded", i)
resolve()
}))
}
await Promise.all(promises)
var roof_manips = new Map()
var no_roof_manips = new Map()
items.forEach((prices, itemname) => {
prices.sort(numberSort);
let m_price = prices[0]
let h_price = m_price
let money_left = MAX_BUY_IN
if (m_price > MAX_MIN_PRICE || m_price < MIN_MIN_PRICE){ } else{
let ind = 0;
while (money_left > 0 && ind < prices.length){
h_price = prices[ind];
money_left -= h_price
if (money_left < 0){
money_left += h_price
break
}
ind++
}
if ((h_price > m_price * MIN_MULTI && h_price >= MIN_FLAT) || ind === prices.length){
if (ind < MIN_ITEMS || ind > MAX_ITEMS){
} else if ( money_left < 0){
} else if (prices.length == ind){
no_roof_manips.set(itemname, MAX_BUY_IN - money_left)
} else{
roof_manips.set(itemname, [h_price, MAX_BUY_IN - money_left])
}
}
}
})
document.getElementById("roof").innerHTML = ""
document.getElementById("no-roof").innerHTML = ""
roof_manips = new Map([...roof_manips.entries()].sort((a, b) => b[1][0] - a[1][0]));
no_roof_manips = new Map([...no_roof_manips.entries()].sort((a, b) => a[1] - b[1]));
roof_manips.forEach((data, name) => {
try{
item_data = itemTable.get(name);
createWidget(item_data.image, item_data.name, data[1], data[0], true, name)
} catch{
createWidget("https://nmsr.nickac.dev/headiso/4bd3c16af6654f229681370b81cb1636", name, data[1], data[0], true, name)
console.log(name, data)
}
})
console.log(no_roof_manips)
no_roof_manips.forEach((data, name) => {
try{
item_data = itemTable.get(name);
createWidget(item_data.image, item_data.name, data, 0, false, name)
} catch{
console.log(name, data)
}
})
}
getItemTable();
// Example usage:
document.getElementById('submitButton').addEventListener('click', function() {
const maxItems = document.getElementById('maxItems').value;
const minItems = document.getElementById('minItems').value;
const maxBuyIn = document.getElementById('maxBuyIn').value;
const minMultiplier = document.getElementById('minMultiplier').value;
const minFlat = document.getElementById('minFlat').value;
const maxFirstPrice = document.getElementById('maxFirstPrice').value;
const minFirstPrice = document.getElementById('minFirstPrice').value;
const hideDungeon = document.getElementById('hideDungeonItems').checked;
const hideDragon = document.getElementById('hideDragonItems').checked;
const hidePetSkin = document.getElementById('hidePetSkins').checked;
const hideFurniture = document.getElementById('hideFurniture').checked;
console.log(maxItems, minItems, maxBuyIn, minMultiplier, minFlat, maxFirstPrice, minFirstPrice, false, hideDungeon, hideDragon, hidePetSkin, hideFurniture)
document.getElementById("roof").innerHTML = "Loading..."
document.getElementById("no-roof").innerHTML = "Loading..."
getManips(maxItems, minItems, maxBuyIn, minMultiplier, minFlat, maxFirstPrice, minFirstPrice, false, hideDungeon, hideDragon, hidePetSkin, hideFurniture);
});
const roof = document.getElementById("roof");
roof.addEventListener("wheel", (evt) => {
evt.preventDefault();
for (let i = 0; i < 300; i++){
setTimeout(()=> {
if (evt.deltaY > 0) {roof.scrollLeft += 3} else{
roof.scrollLeft -= 3;
}
}, i)
}
});
const nroof = document.getElementById("no-roof");
nroof.addEventListener("wheel", (evt) => {
evt.preventDefault();
for (let i = 0; i < 300; i++){
setTimeout(()=> {
if (evt.deltaY > 0) {nroof.scrollLeft += 3} else{
nroof.scrollLeft -= 3;
}
}, i)
}
});