Last active
November 24, 2016 07:50
-
-
Save NanoAi/60f86f9dd408cd79d6decdab73066f48 to your computer and use it in GitHub Desktop.
JQuery, League of Legends Item Build Generator for https://probuilds.net/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var output = {}; | |
output["blocks"] = {[0]: {},[1]: {}}; | |
output["blocks"][0]["items"] = new Array(); | |
output["blocks"][1]["items"] = new Array(); | |
var date = new Date(); | |
date = date.toLocaleDateString(); | |
function builditemfile(datadragon){ | |
var mydata = {}; | |
$("#final-builds>a").find('.bigData').each(function(i,v){ | |
var v = $(v); // Make the value usable. | |
var ply = v.find(".player").text(); | |
var kda = $(v.find(".kda")); | |
var kda_ratio = (Number(kda.find(".green").text()) + Number(kda.find(".gold").text()))/Math.min(1,Number(kda.find(".green").text())); | |
mydata[kda_ratio] = {name: ply, v: v} | |
}) | |
kda_ratio = Math.max.apply(Math, Object.keys(mydata)); | |
mydata = mydata[kda_ratio]; | |
mydata.v.find(".items>.left img").each(function(i,v){ | |
var v = $(v); | |
output["blocks"][0]["items"].push({["id"]: v.attr("data-id"), ["count"]: 1}); | |
}); | |
output["blocks"][0]["type"] = mydata.name+"\'s Build @ "+mydata.v.find("._gold").text()+" Gold (Ratio: "+kda_ratio+") ["+datadragon["lg"]+"]"; | |
// --------------------- // | |
$(".popular-items .bigData").each(function(i,v){ | |
var item = $(v).find(".item[data-type='items']").attr("data-id") | |
if(item){ | |
output["blocks"][1]["items"].push({["id"]: item, ["count"]: 1}); | |
} | |
}); | |
output["blocks"][1]["type"] = "Current Popular Items ["+datadragon["lg"]+"] ("+date+")"; | |
output = JSON.stringify(output); | |
output = output.replace(/\"[0-1]\"\:/g, ""); | |
console.log(output) | |
} | |
$.getJSON("https://ddragon.leagueoflegends.com/realms/na.json", builditemfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Untested, will test it later!