Skip to content

Instantly share code, notes, and snippets.

@rdacquisto
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save rdacquisto/4710a06364bec6cc30ac to your computer and use it in GitHub Desktop.

Select an option

Save rdacquisto/4710a06364bec6cc30ac to your computer and use it in GitHub Desktop.
psnprofiles Trophy Advisor Script for finding game counts on a page. (http://psnprofiles.com/johnwilber/log?earned=unearned)
(function() {
var _games={};
$('img.trophy_image[title]').each(function(){
if(_games[this.title]) {
_games[this.title].count++;
} else {
_games[this.title]={
count: 1,
src: this.src
};
}
});
var _games_array = [];
for (var _game in _games) {
if (_games.hasOwnProperty(_game)) {
_games_array.push({
name: _game,
count: _games[_game].count,
src: _games[_game].src,
});
}
}
_games_array.sort(function(a,b) { return b.count - a.count; } );
var _html = '<ul id="trophies_by_game" style="overflow:hidden;">';
for (var i = 0; i < _games_array.length; i++) {
var _g = _games_array[i];
_html += '<li title="' + _g.name + '" style="margin:1px 3px;float:left;width:126px;height:48px;background: #2f2f2f url(\'/lib/img/layout/bg.png\');color:#fff">';
_html += '<span style="float:right;height:48px;line-height:48px;font-size:26px;width:39px;text-align:center">' + _g.count + '</span>';
_html += '<img class="trophy_image no-border" src="' + _g.src + '">';
_html += '</li>';
};
_html += '</ul>';
$('#trophies_by_game').remove();
$('div.box table.zebra').before(_html);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment