Skip to content

Instantly share code, notes, and snippets.

@lborgav
Last active February 18, 2016 23:55
Show Gist options
  • Save lborgav/7347361725b95358db35 to your computer and use it in GitHub Desktop.
Save lborgav/7347361725b95358db35 to your computer and use it in GitHub Desktop.
Show the number of remaining Duolingo lessons. (Example: http://imgur.com/9r1nOrW)
javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Bvar%20left%20%3D%20%24.map(%24(%22span.lessons-left%22)%2C%20function(el)%7Breturn%20el.textContent%3B%7D).filter(function(el)%7Breturn%20el!%3D%3D%22%22%7D).map(function(el)%7Breturn%20parseInt(el.split(%22%2F%22)%5B1%5D%2C%2010)-parseInt(el.split(%22%2F%22)%5B0%5D%2C%2010)%3B%7D).reduce(function(a%2C%20b)%7Breturn%20a%2Bb%3B%7D)%3Balert(left.toString()%20%2B%20%22%20lessons%20left.%22)%7D)(jQuery.noConflict(true))%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1.7.1%2Fjquery.min.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()
$.map($("span.lessons-left"), function(el){return el.textContent;}).filter(function(el){return el!==""}).map(function(el){return parseInt(el.split("/")[1], 10)-parseInt(el.split("/")[0], 10);}).reduce(function(a, b){return a+b;});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment