// ==UserScript== // @name Duolingo Skill Strength Viewer // @namespace http://blog.fabianbecker.eu/ // @version 0.2.2 // @description Shows individual skill strength // @author Fabian Becker // @match https://www.duolingo.com/* // @downloadURL https://github.com/halfdan/duolingo-skill-strength/raw/master/skill-strength.user.js // @updateURL https://github.com/halfdan/duolingo-skill-strength/raw/master/skill-strength.user.js // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.min.js // @grant none // ==/UserScript== function addGlobalStyle(css) { var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); } addGlobalStyle( ".list-skills { margin: 30px -20px 0 -10px; overflow: auto; max-height: 255px; padding: 10px; }" + ".list-skills-item { padding: 0 10px 0 0; margin: 10px 0 0 0; }" + ".list-skills-item:before { display: table; content: ''; line-height: 0; }" + ".list-skills-item .points { float: right; font-weight: 300; color: #999; }" + ".list-skills-item .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }" ); function inject(f) { //Inject the script into the document var script; script = document.createElement('script'); script.type = 'text/javascript'; script.setAttribute('name', 'skill_strength'); script.textContent = '(' + f.toString() + ')(jQuery)'; document.body.appendChild(script); } inject(f); function f($) { function handleVocabulary(data) { var vocab = data.vocab_overview, fuerte = 0.0, edad = 0.0, ahora = new Date().getTime(); var averageStrength = average(vocab.map(function(v) { return v.strength; })); var averageAge = average(vocab.map(function(v) { return (ahora - v.last_practiced_ms) / 1000 ; })); var medianAge = median(vocab.map(function(v) { return (ahora - v.last_practiced_ms) / 1000 ; })); var zeroStrength = vocab.filter(function(v) { return v.strength === 0; }).length; var skillStrength = calculateSkillStrength(vocab); console.log("Average Strength: " + averageStrength); console.log("Dead words (0 strength): " + zeroStrength); var deadwords = vocab.filter(function(v) { return v.strength === 0; }); var deadwordsDict = _.countBy(deadwords.map(a=>a.skill_url_title),function(word){return word;}); var allwordsDict = _.countBy(vocab.map(a=>a.skill_url_title),function(word){return word;}); console.log("Average Age (hours): " + averageAge / 3600); console.log("Median Age (hours): " + medianAge / 3600); var el = $("
"), list = $("