Created
March 20, 2014 23:43
-
-
Save benwillkommen/9676445 to your computer and use it in GitHub Desktop.
fitocracy total push ups console script
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
(function (options) { | |
if (typeof options !== "object" || typeof options.startDate === "undefined" || options.startDate === "") { | |
options.startDate = new Date("1/1/2000"); | |
} | |
else{ | |
options.startDate = new Date(options.startDate); | |
} | |
if (typeof options !== "object" || typeof options.endDate === "undefined" || options.endDate === "") { | |
var today = new Date(); | |
options.endDate = new Date(today.getTime() + (24 * 60 * 60 * 1000)); | |
} | |
else{ | |
options.endDate = new Date(options.endDate); | |
} | |
$.ajax({ | |
url: "https://www.fitocracy.com/_get_activity_history_json/?activity-id=107", | |
success: function (data) { | |
var totalReps = 0; | |
for (var i = 0; i < data.length; i++) { | |
for (var j = 0; j < data[i].actions.length; j++) { | |
var reps = data[i].actions[j].effort1_imperial, date = new Date(data[i].actions[j].actiondate); | |
if (date >= options.startDate && date <= options.endDate){ | |
totalReps += reps; | |
} | |
} | |
} | |
console.log(totalReps); | |
} | |
}); | |
})({ | |
startDate: "1/1/2013", | |
endDate: "12/31/2013" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment