var leagueName = "Standard"; var totals = new Array(); totals.push({name:"Scroll of Wisdom", amount: 0}); totals.push({name:"Portal Scroll", amount: 0}); totals.push({name:"Orb of Transmutation", amount: 0}); totals.push({name:"Orb of Augmentation", amount: 0}); totals.push({name:"Chromatic Orb", amount: 0}); totals.push({name:"Orb of Alteration", amount: 0}); totals.push({name:"Jeweller's Orb", amount: 0}); totals.push({name:"Orb of Chance", amount: 0}); totals.push({name:"Cartographer's Chisel", amount: 0}); totals.push({name:"Orb of Fusing", amount: 0}); totals.push({name:"Orb of Alchemy", amount: 0}); totals.push({name:"Orb of Scouring", amount: 0}); totals.push({name:"Blessed Orb", amount: 0}); totals.push({name:"Chaos Orb", amount: 0}); totals.push({name:"Orb of Regret", amount: 0}); totals.push({name:"Regal Orb", amount: 0}); totals.push({name:"Gemcutter's Prism", amount: 0}); totals.push({name:"Divine Orb", amount: 0}); totals.push({name:"Exalted Orb", amount: 0}); totals.push({name:"Eternal Orb", amount: 0}); var numTabs = 0; $.ajax({url:'http://www.pathofexile.com/character-window/get-stash-items?league=Standard', async:false}).done( function(data) { numTabs = data.numTabs; console.log("You have " + numTabs.toString() + " tabs."); } ); for (var i = 0;i < numTabs; i++) { var tabUrl = 'http://www.pathofexile.com/character-window/get-stash-items?league=' + leagueName + '&tabs=0&tabIndex=' + i.toString(); console.log("Querying : " + tabUrl); $.ajax({url:tabUrl, async:false}).done( function(data) { for (itemsKey in data.items) { var item = data.items[itemsKey]; var itemTypeFound = false; var currentItem = null; for (var totalsKey in totals) { var itemType = totals[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 totalsKey in totals) { var totalsItem = totals[totalsKey]; console.log(totalsItem.name + " = " + totalsItem.amount.toString()); }