var currencyTotals = new Array(); currencyTotals.push({name:"Scroll of Wisdom", amount: 0, exaltedRatio: 0}); currencyTotals.push({name:"Portal Scroll", amount: 0, exaltedRatio: 0}); currencyTotals.push({name:"Orb of Transmutation", amount: 0, exaltedRatio: 0}); currencyTotals.push({name:"Orb of Augmentation", amount: 0, exaltedRatio: 0}); currencyTotals.push({name:"Chromatic Orb", amount: 0, exaltedRatio: 180}); currencyTotals.push({name:"Orb of Alteration", amount: 0, exaltedRatio: 260}); currencyTotals.push({name:"Jeweller's Orb", amount: 0, exaltedRatio: 150}); currencyTotals.push({name:"Orb of Chance", amount: 0, exaltedRatio: 110}); currencyTotals.push({name:"Cartographer's Chisel", amount: 0, exaltedRatio: 45}); currencyTotals.push({name:"Orb of Fusing", amount: 0, exaltedRatio: 0, exaltedRatio: 40}); currencyTotals.push({name:"Orb of Alchemy", amount: 0, exaltedRatio: 50}); currencyTotals.push({name:"Orb of Scouring", amount: 0, exaltedRatio: 28}); currencyTotals.push({name:"Blessed Orb", amount: 0, exaltedRatio: 40}); currencyTotals.push({name:"Chaos Orb", amount: 0, exaltedRatio: 20}); currencyTotals.push({name:"Orb of Regret", amount: 0, exaltedRatio: 14}); currencyTotals.push({name:"Regal Orb", amount: 0, exaltedRatio: 18}); currencyTotals.push({name:"Gemcutter's Prism", amount: 0, exaltedRatio: 9}); currencyTotals.push({name:"Divine Orb", amount: 0, exaltedRatio: 2}); currencyTotals.push({name:"Exalted Orb", amount: 0, exaltedRatio: 1}); currencyTotals.push({name:"Eternal Orb", amount: 0, exaltedRatio: 0.5}); currencyTotals.push({name:"Mirror of Kalandra", amount: 0, exaltedRatio: 0.0077}); var numTabs = 0; var characters = null; var leagues = new Array(); function getLeagueBreakdown(league) { $.ajax({url:'http://www.pathofexile.com/character-window/get-stash-items?league=' + league, async:false}).done( function(data) { if (data.error != undefined) { console.log(data.error.message); return; } numTabs = data.numTabs; console.log("You have " + numTabs + " tabs."); } ); for (var i = 0;i < numTabs; i++) { var tabUrl = 'http://www.pathofexile.com/character-window/get-stash-items?league=' + league + '&tabs=0&tabIndex=' + i; console.log("Stash : " + (i+1) + "/" + numTabs); $.ajax({url:tabUrl, async:false}).done( function(data) { if (data.error != undefined) { console.log(data.error.message); return; } for (itemsKey in data.items) { var item = data.items[itemsKey]; var itemTypeFound = false; var currentItem = null; for (var totalsKey in currencyTotals) { var itemType = currencyTotals[totalsKey]; if (itemType.name == item.typeLine) { currentItem = itemType; } } if (currentItem != null && item.properties[0].name == 'Stack Size') { currentItem.amount = currentItem.amount + parseInt(item.properties[0].values[0][0].split("/")[0]); } } } ); } for (var characterKey in characters) { var character = characters[characterKey]; if (character.league == league) { console.log("Inventory : " + character.name); var characterUrl = 'http://www.pathofexile.com/character-window/get-items?character=' + character.name; $.ajax({url:characterUrl, async:false}).done( function(data) { if (data.error != undefined) { console.log(data.error.message); return; } for (itemsKey in data.items) { var item = data.items[itemsKey]; var itemTypeFound = false; var currentItem = null; for (var totalsKey in currencyTotals) { var itemType = currencyTotals[totalsKey]; if (itemType.name == item.typeLine) { currentItem = itemType; } } if (currentItem != null && item.properties[0].name == 'Stack Size') { currentItem.amount = currentItem.amount + parseInt(item.properties[0].values[0][0].split("/")[0]); } } } ); } } var result = ""; var exaltedValue = 0; for (var totalsKey in currencyTotals) { var totalsItem = currencyTotals[totalsKey]; result = result + totalsItem.name + " = " + totalsItem.amount + "\n"; if (totalsItem.exaltedRatio != 0) { exaltedValue = exaltedValue + (totalsItem.amount * (1/totalsItem.exaltedRatio)); } } result = result + "\n\n" + "Total value in Exalted Orbs : " + (Math.round(exaltedValue * 100) / 100); console.log(result); for (var totalsKey in currencyTotals) { var totalsItem = currencyTotals[totalsKey]; totalsItem.amount = 0; } } $.ajax({url:'http://www.pathofexile.com/character-window/get-characters', async:false}).done( function(data) { if (data.error != undefined) { console.log(data.error.message); return; } characters = data; for (var characterKey in data) { var character = data[characterKey]; if (leagues.indexOf(character.league) == -1) { leagues.push(character.league) } } console.log("Number of leagues: " + leagues.length); for (var leaguesKey in leagues) { var league = leagues[leaguesKey]; console.log("Getting breakdown for league: " + league); getLeagueBreakdown(league); } } );