Last active
August 29, 2015 14:23
-
-
Save tedpennings/ad843590a01db440b382 to your computer and use it in GitHub Desktop.
Untappd user's favorite beer styles
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
// 1. Go to a page like https://untappd.com/user/thesleepyvegan/beers?filter_type=type&filter_id=all&sort= | |
// 2. Open the Javascript console (Mac Chrome: Apple+Option+J) | |
// 3. Run the following Javascript snippet: | |
$('#style_picker option').map(function(i,e) { return $(e).text() }).splice(1).map(function(s) { var item = /([A-z/\(\) ]+) \((\d+)\)/.exec(s); return [item[1], parseInt(item[2])]; }).sort(function(a,b) { return b[1] - a[1]; }); | |
// 4. Explore the resulting array and enjoy! | |
// Here are comments on what it does. Some browsers may require you to remove the comments for chaining | |
$('#style_picker option') // select the beer text from the style picker dropdown | |
.map(function(i,elem) { return $(elem).text() }) // take the text description of each | |
.splice(1) // make a copy as an Array, dropping the first item ('All Styles') | |
.map(function(styleText) { | |
var item = /([A-z/\(\) ]+) \((\d+)\)/.exec(styleText); // convert 'Altbier (7)' into ["Altbier", 7] | |
return [item[1], parseInt(item[2])] ;}) | |
.sort(function(a,b) { return b[1] - a[1]; }); // sort by score | |
console.log('Go get yourself a beer!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment