-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.js
25 lines (25 loc) · 1 KB
/
script.js
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
function getBestRatioMiners() {
miners = []
cards = document.getElementsByClassName('marketplace-buy-item-card')
for (i = 0; i < cards.length; i++) {
minerName = cards[i].getElementsByClassName('item-title')[0].textContent
price = parseFloat(cards[i].getElementsByClassName('item-price')[0].textContent)
power = cards[i].getElementsByClassName('item-addition-power')[0].textContent.split(' ')
mul = { 'Gh/s': 1, 'Th/s': 1000, 'Ph/s': 1000000 }
unit = mul[power[2]]
power = parseFloat(power[0]) * unit
ratio = power / price
miners.push({ 'Name': minerName, 'Power': power, 'Price': price, 'Ratio': ratio/1000 })
}
return sortMinerByRatio(miners, "desc")
}
function sortMinerByRatio(miners, order) {
let sorted = miners;
if (order == "asc") {
sorted.sort((a, b) => a.Ratio - b.Ratio);
} else if (order == "desc") {
sorted.sort((a, b) => b.Ratio - a.Ratio);
}
return sorted;
}
console.log(getBestRatioMiners())