Created
April 10, 2018 11:33
-
-
Save eioo/30d1b79835e3cde01361c475cc76c451 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
// ==UserScript== | |
// @name OSRS Hiscores fix | |
// @namespace http://google.com | |
// @description Fixes OSRS hiscores layout | |
// @include http://services.runescape.com/m=hiscore_oldschool*/* | |
// @version 1.0 | |
// @grant none | |
// ==/UserScript== | |
const categoryOrder = ['Clue Scrolls (all)', 'Bounty Hunter - Rogue', 'Bounty Hunter - Hunter', 'LMS - Rank']; | |
(function () { | |
fixSidebar(); | |
fixPlayerHiscores(); | |
})(); | |
function fixSidebar() { | |
const categories = document.querySelector('#contentCategory'); | |
if (!categories) return; | |
const links = categories.querySelectorAll('a'); | |
for (let link of links) { | |
if (categoryOrder.includes(link.innerText)) { | |
console.log(link.parentNode.appendChild(link)); | |
} | |
} | |
} | |
function fixPlayerHiscores() { | |
const highlighted = document.querySelector('.right > span[color="#AA0022"]'); | |
if (highlighted) { | |
highlighted.removeAttribute('color'); | |
highlighted.setAttribute('style', 'color: #AA0022'); | |
} | |
const table = document.querySelector('#contentHiscores > table'); | |
if (!table) return; | |
rows = table.querySelectorAll('tr'); | |
for (let row of rows) { | |
let link = row.querySelector('td > a'); | |
if (!link) continue; | |
if (categoryOrder.includes(link.innerText)) { | |
row.parentNode.appendChild(row); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment