Created
December 17, 2022 13:26
-
-
Save VlatkoStojkoski/432e1e7514fef95893f98b5b0f38a446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const titleEl = document.querySelector('.training-content > table:nth-child(1) > caption:nth-child(1)') | |
const sortButton = document.createElement('button'); | |
sortButton.innerText = 'Сортирај'; | |
sortButton.style.setProperty('float', 'right'); | |
sortButton.addEventListener('click', () => { | |
document.querySelector('body > div.page-container > div.main > div.main-content > div:nth-child(3) > div > table > tbody').innerHTML = [...document.querySelectorAll('body > div.page-container > div.main > div.main-content > div:nth-child(3) > div > table > tbody > tr > td:nth-child(5) > a')].sort((a, b) => +a.innerText.match(/(?<= \()\d+/)[0] > +b.innerText.match(/(?<= \()\d+/)[0] ? -1 : +a.innerText.match(/(?<= \()\d+/)[0] < +b.innerText.match(/(?<= \()\d+/)[0] ? 1 : 0 ).map((a) => a.parentElement.parentElement.outerHTML).join(''); | |
}); | |
titleEl.appendChild(sortButton); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment