-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatches.js
63 lines (55 loc) · 1.86 KB
/
matches.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function updateMatchesTime() {
document.querySelectorAll(".guide-same-day-matches span").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 {
e.innerText = `${hours}:${mins}am`;
}
});
document.querySelectorAll(".matchTime").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 (e.innerText != "LIVE") {
if (hours < 10) e.innerText = `${hours.substring(1)}:${mins} AM`;
else e.innerText = `${hours}:${mins} AM`;
}
});
}
function updateMatchesStyles() {
document.querySelectorAll(".toggle-match-notifications-button").forEach(e => {
e.style.marginLeft = "-5px";
e.style.marginRight = "5px";
});
document.querySelectorAll(".matchInfo").forEach(e => {
e.style.flex = "0 0 55px";
e.style.textAlign = "center";
});
}
const matchesObserver = new MutationObserver((mutations, observer) => {
const targetText = mutations[mutations.length - 1].target.textContent.toLowerCase();
if (targetText.includes("am") || targetText.includes("pm")) {
console.log("contains");
observer.disconnect();
return;
}
updateMatchesTime();
});
updateMatchesTime();
updateMatchesStyles();
matchesObserver.observe(document.querySelector(".matchTime"), { childList: true });