blob: 7ebafd5fac2329f6dfa197cd6fd4e331d3341f53 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// ==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);
});
}
|