-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifier.js
More file actions
40 lines (35 loc) · 1.08 KB
/
notifier.js
File metadata and controls
40 lines (35 loc) · 1.08 KB
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
Notification.requestPermission().then(function(result) {
console.log(result);
});
function showNotification(name, imageUrl) {
new Notification('SINoAlice Event',
{ body: name + ' begins in 5 minutes!', icon: imageUrl }
);
};
let ignore = [];
setInterval(function() {
const rows = Array.from(
document
.getElementsByTagName("table")[1]
.getElementsByTagName("tbody")[0]
.children
)
.forEach(function(row) {
const timeLeft = row.children[0].textContent.split(" ")[2];
const name = row.children[3].textContent;
const id = row.children[1].textContent + name;
if (ignore.includes(id)) {
return;
}
if (timeLeft.startsWith("00:05")) {
showNotification(
name,
row.children[3].getElementsByTagName("img")[0].attributes["src"].value
);
ignore.push(id);
}
});
}, 5000);
setInterval(function() {
ignore = [];
}, 30 * 60 * 1000);