-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatch.js
33 lines (28 loc) · 981 Bytes
/
match.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function updateMatchTime() {
document.querySelectorAll(".timeAndEvent .time").forEach(e => {
const [hours, mins] = e.innerText.split(":");
if (hours > 12) {
e.innerText = `${hours - 12}:${mins} PM`;
}
else if (hours == 0) {
e.innerText = `12:${mins} AM`;
}
else if (hours == 12) {
e.innerText = `12:${mins} PM`;
}
else {
if (hours < 10) e.innerText = `${hours.substring(1)}:${mins} AM`;
else e.innerText = `${hours}:${mins} AM`;
}
});
}
const matchObserver = new MutationObserver((mutations, observer) => {
const targetText = mutations[0].target.textContent.toLowerCase();
if (targetText.includes("am") || targetText.includes("pm")) {
observer.disconnect();
return;
}
updateMatchTime();
});
updateMatchTime();
matchObserver.observe(document.querySelector(".timeAndEvent .time"), { childList: true });