Created
May 7, 2024 17:39
-
-
Save tomtobac/4eb57c324a299ab4b0c91a16e65272be to your computer and use it in GitHub Desktop.
v2
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"; | |
const root = document.querySelector("#rankings-page"); | |
const observer = new MutationObserver(() => { | |
formatRespawnTime(); | |
}); | |
observer.observe(root, { | |
childList: true, | |
subtree: true, | |
}); | |
formatRespawnTime(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment