[GC] - Music Skills Sorting

Sorts instruments by smallest to largest so you can more easily see what you're missing.

  1. // ==UserScript==
  2. // @name [GC] - Music Skills Sorting
  3. // @namespace https://greasyfork.org/en/users/1225524-kaitlin
  4. // @match https://www.grundos.cafe/instruments/*
  5. // @version 1.0
  6. // @license MIT
  7. // @description Sorts instruments by smallest to largest so you can more easily see what you're missing.
  8. // @author Cupkait
  9. // @icon https://i.imgur.com/4Hm2e6z.png
  10. // ==/UserScript==
  11.  
  12. const grid = document.querySelectorAll('.instrument-item');
  13. const parent = grid[0]?.parentNode;
  14.  
  15. const instrumentsWithSkill = Array.from(grid).map(i => {
  16. const skillBar = i.querySelector('.skill-bar');
  17. const skill = skillBar ? parseInt(getComputedStyle(skillBar).width, 10) : 0;
  18. return { element: i, skill: skill };
  19. });
  20.  
  21. instrumentsWithSkill.sort((a, b) => a.skill - b.skill);
  22. instrumentsWithSkill.forEach(item => parent.removeChild(item.element));
  23. instrumentsWithSkill.forEach(item => parent.appendChild(item.element));