Guest User

Duolingo XP Bar for Greasemonkey/TamperMonkey

a guest
Jan 23rd, 2016
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        th23 Duolingo
  3. // @namespace   th23-duolingo
  4. // @include     https://www.duolingo.com/*
  5. // @include     http://www.duolingo.com/*
  6. // @version     1
  7. // @grant       none
  8. // ==/UserScript==
  9.  
  10. function inject(f) { //Inject the script into the document
  11.     var script;
  12.     script = document.createElement('script');
  13.     script.type = 'text/javascript';
  14.     script.setAttribute('name', 'lesson_review');
  15.     script.textContent = '(' + f.toString() + ')(jQuery)';
  16.     document.head.appendChild(script);
  17. }
  18. inject(f);
  19.  
  20. function f($) {
  21.     function th23DuolingoProgress() {
  22.         if($('#app').hasClass('home') || $('#app').hasClass('comment better-comment')) {
  23.             if(!$('.sidebar-progress-main').length) {
  24.                 var th23LanguageData = window.duo.user.attributes.language_data[window.duo.user.attributes.learning_language];
  25.                 $('.inner').before('<div class="box-colored bg-white"><h2>Próximo Nível</h2><div class="sidebar-progress-main"><div title="' +  th23LanguageData.level_percent + '% concluído, ' + th23LanguageData.points + 'XP no total' + '" data-toggle="tooltip" class="language-progress-bar-small"><div class="padder"><div style="width: ' + th23LanguageData.level_percent + '%; max-width: 100%;" class="bar"></div></div><span class="level level-current">' + th23LanguageData.level + '</span><span class="level level-next">' + th23LanguageData.next_level + '</span></div><ul class="sidebar-stats" style="font-size: 15px"><li>Faltam <strong>' + th23LanguageData.level_left + 'XP</strong> para o próximo nível</li></ul></div></div>');
  26.             }
  27.         }
  28.     }
  29.     $(document).ready(function() {
  30.         th23DuolingoProgress();
  31.     });
  32.     $(document).ajaxComplete(function() {
  33.         th23DuolingoProgress();
  34.     });
  35. }
Advertisement
Add Comment
Please, Sign In to add comment