Duolingo lessons to go

If you are using Duolingo and are nearing the end of the tree, you might be anxious to know how many lessons are left till you can claim your tree is all golden. Here’s a small Javascript snippet that allows to get that from the main language page on the site:

var lessons = $('.lessons-left:not(:empty)').map(function() {
    return this.innerHTML
})

var listToInt = function(list) {
    return _.map(list, function(e) {
        return parseInt(e)
    })
}

var expanded = _.map(lessons, function(e) {
    var list = e.split('/')
    return listToInt(list)
})

var done = _.collect(expanded, _.head)
var total = _.collect(expanded, _.last)

var sum = function(list) {
    return _.reduce(list, function(a, b) { 
        return a + b
    }, 0)
}

console.log("lessons to go:", sum(total) - sum(done))

Here’s how it can be used:

  • Open Chrome Developer Tools window by pressing F12
  • Go to Sources tab
  • Go to Snippets sub-tab
  • On the left, right-click and select New to create a new snippet. Name it whatever you like, I named it “Duolingo – lessons to go”
  • Put the above code in the snippet source tab that opens
  • Run it by pressing Ctrl + Enter or by clicking on a play icon in the top right of the Developer Tools window

It should print your tree leftover in the console. Now let’s get that number down to 0!