[GC] - Music Skills Sorting

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

// ==UserScript==
// @name         [GC] - Music Skills Sorting
// @namespace    https://greasyfork.org/en/users/1225524-kaitlin
// @match        https://www.grundos.cafe/instruments/*
// @version      1.0
// @license      MIT
// @description  Sorts instruments by smallest to largest so you can more easily see what you're missing.
// @author       Cupkait
// @icon         https://i.imgur.com/4Hm2e6z.png
// ==/UserScript==

const grid = document.querySelectorAll('.instrument-item');
const parent = grid[0]?.parentNode;

const instrumentsWithSkill = Array.from(grid).map(i => {
    const skillBar = i.querySelector('.skill-bar');
    const skill = skillBar ? parseInt(getComputedStyle(skillBar).width, 10) : 0;
    return { element: i, skill: skill };
});

instrumentsWithSkill.sort((a, b) => a.skill - b.skill);
instrumentsWithSkill.forEach(item => parent.removeChild(item.element));
instrumentsWithSkill.forEach(item => parent.appendChild(item.element));