Created
January 15, 2023 18:10
-
-
Save tomtobac/ecd366b2b72bbf1aa64f6612735ff3be 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
var level = 60; | |
var table = document.querySelector('#Container'); | |
var links = table.querySelectorAll('.tt'); | |
var raids = Array.from(links).map((link) => { | |
const id = link.attributes["href"].value.substring(1); | |
const name = link.querySelector('u').innerText; | |
let status = 'not info';; | |
if (link.querySelector('font')) { | |
status = link.querySelector('font').attributes['color'].value === 'red' ? 'dead' : 'alive'; | |
} | |
let respawnTime = undefined; | |
if (status === 'dead') { | |
respawnTime = link.querySelector('p').textContent.substring(12, 28) + ' UTC'; | |
} | |
let level = 0; | |
const text = link.querySelector('.middle').textContent.trim(); | |
const regex = text.match(/Level: (\d+)/); | |
if (regex) { | |
level = parseInt(regex[1]); | |
} | |
return { | |
id, | |
name, | |
status, | |
respawnTime, | |
level, | |
}; | |
}); | |
var aliveRaids = raids.filter((raid) => raid.status === 'alive'); | |
var deadRaids = raids | |
.filter((raid) => raid.status === 'dead') | |
.sort((p, c) => new Date(p.respawnTime) < new Date(c.respawnTime) ? -1 : 1) | |
.map(raid => ({ ...raid, respawnTime: new Date(raid.respawnTime).toLocaleString()})); | |
var sorted = aliveRaids.concat(deadRaids).filter(raid => raid.level > level); | |
/* | |
copy(raids.reduce((prev, raid) => { | |
prev[raid.id] = { | |
name: raid.name, | |
level: raid.level | |
} | |
return prev; | |
}, {})); | |
*/ | |
console.table(sorted) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment