Duolingo Restore Golden

Duolingo used to show a golden circle around the skill icon when you reach level 5. After they introduced the legendary level, this golden circle is removed and the circle ramains gray. This script restores the golden circle.

  1. // ==UserScript==
  2. // @name Duolingo Restore Golden
  3. // @description Duolingo used to show a golden circle around the skill icon when you reach level 5. After they introduced the legendary level, this golden circle is removed and the circle ramains gray. This script restores the golden circle.
  4. // @version 0.1.0
  5. // @author Betty
  6. // @namespace https://github.com/BettyJJ
  7. // @match https://*.duolingo.com/*
  8. // @run-at document-idle
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14.  
  15. init();
  16.  
  17.  
  18. /**
  19. * initialize
  20. */
  21. function init() {
  22.  
  23. watch_page();
  24.  
  25. }
  26.  
  27.  
  28. function watch_page() {
  29. const observer = new MutationObserver(function (mutationlist) {
  30. for (const { addedNodes } of mutationlist) {
  31. for (const node of addedNodes) {
  32. if (!node.tagName) continue; // not an element
  33.  
  34. if (node.classList.contains('_15U-t')) {
  35. restore_golden(node);
  36. }
  37.  
  38. }
  39. }
  40. });
  41. observer.observe(document.body, { childList: true, subtree: true });
  42. }
  43.  
  44.  
  45. /**
  46. * restore the golden circle
  47. * @param {Node} node Dom Node
  48. */
  49. function restore_golden(node) {
  50. // only works for skills at level 5
  51. if (node.querySelector('.GkDDe') && node.querySelector('.GkDDe').textContent === '5') {
  52. node.querySelector('svg._2rKNN > g > path').style.fill = '#ffd90b';
  53. }
  54. }
  55.  
  56.  
  57. })();