Skip to content

Instantly share code, notes, and snippets.

@igniuss
Created December 27, 2018 22:30
Show Gist options
  • Save igniuss/ae00202c2b7aecaa325a39d2405b1fc5 to your computer and use it in GitHub Desktop.
Save igniuss/ae00202c2b7aecaa325a39d2405b1fc5 to your computer and use it in GitHub Desktop.
Returns a json file with all steam games played over 2 hours.
/*
Instructions:
Head to https://steamcommunity.com/id/{your_steam_id}/games/?tab=all
Execute this script in console
*/
var games = document.getElementsByClassName("gameListRow");
var result = []
for(var i = 0; i < games.length; i++) {
var hoursE = games[i].getElementsByClassName("hours_played")[0];
if(hoursE != null && hoursE.outerText){
var hours = parseFloat(hoursE.outerText.split(' ')[0]);
if(hours > 2.0) {
result.push(games[i].id.replace("game_",""));
} else{
console.log(hours);
}
}
}
// Save data
var data = JSON.stringify(result, undefined, 4);
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvent');
a = document.createElement('a');
a.download = "results.json";
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment