Skip to content

Instantly share code, notes, and snippets.

@r3Fuze
Last active August 29, 2015 14:04
Show Gist options
  • Save r3Fuze/69ed2f40fd223748a8b2 to your computer and use it in GitHub Desktop.
Save r3Fuze/69ed2f40fd223748a8b2 to your computer and use it in GitHub Desktop.
var leagueName = "Standard";
var effects = [];
var numTabs = 0;
var characters = [];
var charEffects = [];
var leagues = ["Standard", "Hardcore"];
$(document.body).append("<div style=\"z-index: 10000; background: white; color: black; border: 2px solid black; padding: 10px; width: 900px; height: 500px; position: absolute; left: 50%; top: 50%; margin-left: -450px; margin-top: -250px; overflow-y: auto; line-height: 25px;\" id=\"modal\">Please select your league.<br><div class=\"_leagues\"></div></div>");
$modal = $("#modal");
function log(msg, nobr) {
$modal.append(msg + (nobr ? "" : "<br>"));
}
$.ajax({url: "http://api.pathofexile.com/leagues?type=event", async: false}).done(
function (data) {
for (var i = 0; i < data.length; i++) {
leagues.push(data[i].id);
}
}
);
leagues.forEach(function(league, i) {
$("._leagues").append("<a class=\"_mtx\" href=\"#\">" + league + "</a>" + (i === leagues.length - 1 ? "<br>" : ", "), true);
});
$("a._mtx").on("click", function(e) {
e.preventDefault();
leagueName = $(this).html();
console.log(leagueName);
$("._leagues").remove();
$modal.html("Please wait.. The page will be unresponsive for a few seconds.<br>");
log("<button onclick=\"$modal.remove()\">Close</button>");
setTimeout(start, 100);
});
log("<button onclick=\"$modal.remove()\">Close</button>");
function start() {
$.ajax({url: "http://www.pathofexile.com/character-window/get-stash-items?league=" + leagueName, 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];
if (item.cosmeticMods) {
effects.push({
cosmeticMods: item.cosmeticMods,
typeLine: item.typeLine,
inventoryId: item.inventoryId,
x: item.x + 1,
y: item.y + 1
});
}
}
}
);
}
$.ajax({url: "http://www.pathofexile.com/character-window/get-characters?league=" + leagueName, async: false}).done(
function (data) {
console.log("You have " + data.length + " characters.");
for (var i = 0; i < data.length; i++) {
characters.push(data[i].name);
}
}
);
for (var i = 0; i < characters.length; i++) {
var char = characters[i];
console.log("Querying: " + char);
$.ajax({url: "http://www.pathofexile.com/character-window/get-items?character=" + char, async: false}).done(
function (data) {
for (itemsKey in data.items) {
var item = data.items[itemsKey];
if (item.cosmeticMods) {
charEffects.push({
charName: char,
cosmeticMods: item.cosmeticMods,
typeLine: item.typeLine,
league: data.character.league
});
}
}
}
);
}
$modal.html("");
for (var charEffect in charEffects) {
var e = charEffects[charEffect];
for (var i = 0; i < e.cosmeticMods.length; i++) {
e.cosmeticMods[i] = e.cosmeticMods[i].replace("Has ", "");
}
log("- \"" + e.cosmeticMods.join(", ") + "\" on \"" + e.typeLine + "\" on char \"" + e.charName + "\" in league \"" + e.league + "\"");
}
log("<hr>", true);
for (var effect in effects) {
var e = effects[effect];
for (var i = 0; i < e.cosmeticMods.length; i++) {
e.cosmeticMods[i] = e.cosmeticMods[i].replace("Has ", "");
}
log("- \"" + e.cosmeticMods.join(", ") + "\" on \"" + e.typeLine + "\" in " + e.inventoryId + " at " + e.x + ", " + e.y);
}
log("<button onclick=\"$modal.remove()\">Close</button>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment