// ==UserScript== // @name vim-fmi точки // @description Добавя брой натиснати клавиши във всяка страница на решения // // @version 1.2 // @license MIT // @author Syndamia // // @source https://gitlab.com/Syndamia/userscripts/-/blob/main/vim-fmi-keystrokes.js // @supportURL https://gitlab.com/Syndamia/userscripts/-/issues // @homepage https://gitlab.com/Syndamia/userscripts/ // @icon https://vim-fmi.bg/favicon.png // // @namespace Syndamia // @match *://*vim-fmi.bg/tasks/* // @run-at document-end // ==/UserScript== if (window.location.pathname.endsWith('solutions')) { document.getElementsByTagName('tbody')[0].childNodes.forEach((x) => { if (x.tagName != 'TR') return; var countElem = document.createElement('div'); countElem.style.display = 'inline-block'; countElem.style.fontWeight = 'bold'; countElem.innerText = x.children[1].children[0].children.length; x.children[1].insertBefore(countElem, x.children[1].firstChild); }); var sortBtn = document.createElement('div'); sortBtn.classList.add('action'); sortBtn.innerText = 'Сортирай по решения'; document.getElementsByClassName('main')[0].children[2].appendChild(sortBtn); sortBtn.addEventListener('click', function () { var rows = [...document.getElementsByClassName('solutions')[0].children[1].children]; rows.sort(function (a, b) { var aInt = parseInt(a.children[1].children[0].innerText); var bInt = parseInt(b.children[1].children[0].innerText); return aInt > bInt || (aInt == bInt && a.children[2].innerText > b.children[2].innerText); }); document.getElementsByClassName('solutions')[0].children[1].replaceChildren(...rows); }); } else { document.getElementsByTagName('ul')[3].childNodes.forEach((x) => { if (x.tagName != 'LI') return; var countElem = document.createElement('span'); countElem.style.verticalAlign = 'middle'; countElem.innerText = x.children[0].children.length; x.insertBefore(countElem, x.firstChild); }); }