Skip to content

Instantly share code, notes, and snippets.

@tristaaan
Last active November 18, 2016 06:37
Show Gist options
  • Save tristaaan/928e926a4271dd424c00a9937f423995 to your computer and use it in GitHub Desktop.
Save tristaaan/928e926a4271dd424c00a9937f423995 to your computer and use it in GitHub Desktop.
Duolingo word scraper
// found from http://pastebin.com/jnEViBPz
// simple run in console on duolingo homepage
var $words = $('<table><thead><tr><th>Language</th><th>Category</th><th>Word</th><th>Strength</th></thead><table>');
var ld=duo.user.attributes.language_data;
var count = 0;
var waiting = 0;
for(l in ld){
waiting = ld[l].skills.models.length;
ld[l].skills.models.forEach(function(e){
var t=e.attributes;
if(t.progress_percent>0){
$.get("/skills/"+t.language+"/"+t.url_title,function(e){
e.path.forEach(function(e){
if(e.words&&e.strength>0){
e.words.forEach(function(n){
count++;
var r="<tr>";r+="<td>"+l+"</td>";
r+="<td>"+t.name+"</td>";
r+="<td>"+n+"</td>";
r+="<td>"+e.strength+"</td>";
r+="</tr>";
$words.append(r)
})
}
})
if(--waiting===0) {
$words.append('<tr><td colspan="3">TOTAL</td><td>'+count+'</td></tr>');
$('body').html($words);
}
})
} else {
waiting--;
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment