Last active
August 29, 2015 14:05
-
-
Save jeroenlammerts/c5d8a5f56662264a90cb to your computer and use it in GitHub Desktop.
Check batch badges status on untappd
This file contains hidden or 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
// ==UserScript== | |
// @name Untappd show badges | |
// @namespace http://www.jeroenlammerts.nl/untappd | |
// @version 0.1 | |
// @description Untappd show badges | |
// @match https://untappd.com/user/#username#/badges | |
// @copyright 2014, Jeroen Lammerts | |
// ==/UserScript== | |
$('.badges .item.retired').hide().remove(); | |
$('.badge-list .header').append('<a href="#" class="checkBadges" style="margin-top: 10px; display: inline-block; background:#000; color: #fff; font-size: 14px; padding: 5px;">Check badges!!</a>'); | |
$('.checkBadges').live('click', function(e) { | |
e.preventDefault(); | |
checkBadges(); | |
}); | |
$('.badge-list .header').append('<p> </p>'); | |
function checkBadges(){ | |
$('.badges .item').each(function(index, el) { | |
if($(this).children('.next-level').length){ | |
var badgeID = $(this).children('.next-level').children('a').attr('data-badge-id'); | |
} else { | |
var badgeID = $(this).children('.unearned-badge').attr('data-badge-id'); | |
} | |
if(badgeID){ | |
$.get('https://untappd.com/apireqs/badgestatus/' + badgeID, function( badge ) { | |
var badge = badge.result; | |
var beersNeeded = badge.badge_status.required - badge.badge_status.current; | |
if(beersNeeded < 3 && beersNeeded > 0){ | |
var txt = '<p>' + badge.badge_name + ': ' + beersNeeded + ' bier nodig</p>'; | |
$('.badge-list .header').append(txt); | |
} | |
}); | |
} else { | |
$(this).hide().remove(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo