Last active
May 7, 2024 17:43
-
-
Save tomtobac/55c52d82eb5cd90b335724fcbba869e7 to your computer and use it in GitHub Desktop.
Formats the respawn time of raid bosses in the browser's timezone instead of UTC.
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 L2Reborn Raid Boss Status Date Fix | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-05-06 | |
// @description Formats the respawn time of raid bosses in the browser's timezone instead of UTC. | |
// @author discord.com/users/nymphadora_ | |
// @match https://l2reborn.org/seasons-h5/raid-boss-status-s2/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=l2reborn.org | |
// @grant none | |
// ==/UserScript== | |
const formatRespawnTime = () => { | |
const rows = Array.from( | |
document.querySelectorAll(".rankings__content__table__content") | |
); | |
rows | |
.map((row) => row.children[3]) | |
.filter((cell) => !cell.classList.contains("formatted")) | |
.forEach((cell) => { | |
const respawnTime = cell.textContent.trim(); | |
if (respawnTime) { | |
const [date, minTime, , maxTime] = respawnTime.split(" "); | |
const newDate = new Date(`${date} ${minTime} UTC`); | |
const maxDate = new Date(`${date} ${maxTime} UTC`); | |
cell.textContent = `${newDate.toLocaleDateString()} ${newDate.toLocaleTimeString()} - ${maxDate.toLocaleTimeString()}`; | |
cell.classList.add("formatted"); | |
} | |
}); | |
}; | |
(function () { | |
"use strict"; | |
setInterval(formatRespawnTime, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment