NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name bots4 Fight List Mod // @version 1.2 // @description Makes the fight list sortable // @match http://bots4.net/fight* // @require https://kryogenix.org/code/browser/sorttable/sorttable.js // @updateURL https://openuserjs.org/meta/Clay_Banger/bots4_Fight_List_Mod.meta.js // @license MIT // ==/UserScript== if(document.title == "fight list - bots4") { //we are in the right place. /********* Makes the fight list sortable ***********/ var content = document.getElementById("content"); var table = content.getElementsByClassName("tight")[0]; table.classList.add("sortable"); //make some columns not sortable var ths = table.getElementsByTagName("th"); //logo, level, botname, username, fight ths[0].classList.add("sorttable_nosort"); ths[1].classList.add("sorttable_nosort"); ths[2].classList.add("sorttable_nosort"); ths[3].classList.add("sorttable_nosort"); ths[11].classList.add("sorttable_nosort"); //show that the table is now sortable var style = document.createElement("style"); style.innerHTML = "table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after { content: ' \\25B4\\25BE' }}"; content.appendChild(style); //fixes to make some columns sortable var fixTH = document.createElement("th"); fixTH.innerHTML = "energy ratio"; ths[6].removeAttribute("colspan"); ths[0].parentNode.insertBefore(fixTH, ths[7]); var botrows = document.getElementsByClassName("botrow"); for(var i=0;i<botrows.length;i++){ var tds = botrows[i].getElementsByTagName("td"); //fix colspan sorting issues (this is due to the way energy is displayed) if(tds[6].hasAttribute("colspan")) { tds[6].removeAttribute("colspan"); botrows[i].insertBefore(tds[6].cloneNode(true),tds[7]); tds[7].style.borderLeft = "0px"; tds[6].style.borderRight = "0px"; } //clans if(tds[4].getElementsByTagName("a").length === 0) { tds[4].setAttribute("sorttable_customkey",""); } else { tds[4].setAttribute("sorttable_customkey",tds[4].getElementsByTagName("a")[0].innerHTML.toLowerCase()); } } }