-
Notifications
You must be signed in to change notification settings - Fork 3
/
school.js
67 lines (63 loc) · 2.3 KB
/
school.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
64
65
66
67
async function getIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
console.error('Error fetching IP:', error);
return null;
}
}
function checkHoraireDate(h,m,h1,m1) {
var d = new Date();
var d1 = new Date();d1.setMinutes(m);d1.setHours(h);
var d2 = new Date();d2.setMinutes(m1);d2.setHours(h1);
if (d > d1 && d < d2) {
return true
}
return false
}
function checkHoraire() {
var horaire = false
var horaire = !horaire && checkHoraireDate('8','5','9','20') ? true : horaire
var horaire = !horaire && checkHoraireDate('9','30','10','45') ? true : horaire
var horaire = !horaire && checkHoraireDate('10','50','11','15') ? true : horaire
var horaire = !horaire && checkHoraireDate('12','30','13','45') ? true : horaire
var horaire = !horaire && checkHoraireDate('13','55','15','10') ? true : horaire
if (localStorage.getItem('bypass') == 'true') {
var horaire = false
}
return horaire
}
async function checkIP() {
var ip = await getIP();
if (ip == null) {
var ip = atob(localStorage.getItem('lastIP'))
} else {
localStorage.setItem('lastIP',btoa(ip))
}
if (ip === '206.167.189.66') {
if (checkHoraire() == true) {
// display iframe from clock
// url = https://franck403.github.io/phoneClock/
var iframeUrl = 'https://franck403.github.io/phoneClock/'
var iframess = document.createElement('iframe')
iframess.src = iframeUrl
iframess.style.cssText = "position: fixed;top: 0px;left: 0px;z-index: 9999;background: black;margin: 0px;padding: 0px;border: none;width: 100vw;visibility: visible;display: block;height: 100vh;overflow: scroll;"
document.body.append(iframess)
window.horaireInterval = setInterval(() => {
// run every second
if (!checkHoraire()) {
window.horaireIntervalIframe.remove()
clearInterval(window.horaireInterval)
checkIP();
}
}, 1000);
}
} else {
setTimeout(() => {
checkIP();
}, 1000);
}
}
checkIP();