|
3 | 3 |
|
4 | 4 | pages.alle = (async () => {
|
5 | 5 |
|
6 |
| - chrome.storage.local.get(["light"], (result) => { |
7 |
| - if (result.light) document.body.classList.add("light-theme") |
8 |
| - }) |
9 |
| - chrome.storage.local.get(["fri"], async (result) => { |
10 |
| - if (result.fri) { |
11 |
| - const fGetXML = async (skoleId, elevId) => { |
12 |
| - const response = await getBackend("skemaEnd", async () => { |
13 |
| - return new Promise(async res2 => { |
14 |
| - var xhttpUrl = "https://www.lectio.dk/lectio/" + skoleId + "/SkemaNy.aspx?type=elev&elevid=" + elevId; |
15 |
| - var xhttp = new XMLHttpRequest(); |
16 |
| - xhttp.onreadystatechange = function () { |
17 |
| - if (this.readyState == 4 && this.status == 200) { |
18 |
| - const skema = xhttp.responseXML.querySelector(".s2skema tbody tr:nth-child(4)"); |
19 |
| - |
20 |
| - const currentDate = new Date() |
21 |
| - const currentWeekday = new Date().getDay(); |
22 |
| - const skemaDay = skema.querySelector(`td:nth-child(${currentWeekday + 1})`); |
23 |
| - const skemaBlock = skemaDay.querySelector("div"); |
24 |
| - let theEnd = new Date(); |
25 |
| - |
26 |
| - const lectures = skemaBlock.querySelectorAll(".s2skemabrik:not(.s2cancelled)"); |
27 |
| - for (const lecture of lectures) { |
28 |
| - if (parseInt(xhttp.responseXML.querySelector(`.s2dayHeader td:nth-child(` + (currentWeekday + 1) + `)`).innerText.split("/")[0].match(/\d+/g)[0]) !== new Date().getDate()) continue; |
29 |
| - // const start = lecture.getAttribute("data-additionalinfo").match(/\d+:\d+/)[0] |
30 |
| - const end = lecture.getAttribute("data-additionalinfo").match(/\d+:\d+/g).pop() |
31 |
| - const endTime = new Date( |
32 |
| - currentDate.getFullYear(), |
33 |
| - currentDate.getMonth(), |
34 |
| - currentDate.getDate(), |
35 |
| - end.split(":")[0], |
36 |
| - end.split(":")[1] |
37 |
| - ).getTime(); |
38 |
| - theEnd = endTime |
39 |
| - } |
40 |
| - res2(theEnd) |
| 6 | + // chrome.storage.local.get(["light"], (result) => { |
| 7 | + // if (result.light) document.body.classList.add("light-theme") |
| 8 | + // }) |
| 9 | + getSetting("Fri Counter").then(async isEnabled => { |
| 10 | + if (!isEnabled) return |
| 11 | + const fGetXML = async (skoleId, elevId) => { |
| 12 | + const response = await getBackend("skemaEnd", async () => { |
| 13 | + return new Promise(async res2 => { |
| 14 | + var xhttpUrl = "https://www.lectio.dk/lectio/" + skoleId + "/SkemaNy.aspx?type=elev&elevid=" + elevId; |
| 15 | + var xhttp = new XMLHttpRequest(); |
| 16 | + xhttp.onreadystatechange = function () { |
| 17 | + if (this.readyState == 4 && this.status == 200) { |
| 18 | + const skema = xhttp.responseXML.querySelector(".s2skema tbody tr:nth-child(4)"); |
| 19 | + |
| 20 | + const currentDate = new Date() |
| 21 | + const currentWeekday = new Date().getDay(); |
| 22 | + const skemaDay = skema.querySelector(`td:nth-child(${currentWeekday + 1})`); |
| 23 | + const skemaBlock = skemaDay.querySelector("div"); |
| 24 | + let theEnd = new Date(); |
| 25 | + |
| 26 | + const lectures = skemaBlock.querySelectorAll(".s2skemabrik:not(.s2cancelled)"); |
| 27 | + for (const lecture of lectures) { |
| 28 | + if (parseInt(xhttp.responseXML.querySelector(`.s2dayHeader td:nth-child(` + (currentWeekday + 1) + `)`).innerText.split("/")[0].match(/\d+/g)[0]) !== new Date().getDate()) continue; |
| 29 | + // const start = lecture.getAttribute("data-additionalinfo").match(/\d+:\d+/)[0] |
| 30 | + const end = lecture.getAttribute("data-additionalinfo").match(/\d+:\d+/g).pop() |
| 31 | + const endTime = new Date( |
| 32 | + currentDate.getFullYear(), |
| 33 | + currentDate.getMonth(), |
| 34 | + currentDate.getDate(), |
| 35 | + end.split(":")[0], |
| 36 | + end.split(":")[1] |
| 37 | + ).getTime(); |
| 38 | + theEnd = endTime |
41 | 39 | }
|
| 40 | + res2(theEnd) |
42 | 41 | }
|
43 |
| - xhttp.open("GET", xhttpUrl, true); |
44 |
| - xhttp.responseType = "document"; |
45 |
| - xhttp.send(); |
46 |
| - }) |
47 |
| - }, 1000 * 60 * 60) |
48 |
| - const headerNav = await first("header[role='banner'] nav .floatLeft"); |
49 |
| - headerNav.innerHTML += `<p class="fricount">Du har fri om <strong id="fritid"></strong> <p>`; |
50 |
| - setInterval(() => { |
51 |
| - const timeUntilDate = response - (new Date()) |
52 |
| - let htmlToApply = formatTime(timeUntilDate); |
53 |
| - document.getElementById("fritid").innerText = htmlToApply; |
54 |
| - }, 1000) |
55 |
| - } |
56 |
| - |
57 |
| - const location = window.location.href; |
58 |
| - fGetXML(location?.split("/")?.[4], location?.split("?elevid=")?.[1]?.split("&")[0] ?? location?.split("&elevid=")?.[1]?.split("&")?.[0]); |
| 42 | + } |
| 43 | + xhttp.open("GET", xhttpUrl, true); |
| 44 | + xhttp.responseType = "document"; |
| 45 | + xhttp.send(); |
| 46 | + }) |
| 47 | + }, 1000 * 60 * 60) |
| 48 | + const headerNav = await first("header[role='banner'] nav .floatLeft"); |
| 49 | + headerNav.innerHTML += `<p class="fricount">Du har fri om <strong id="fritid"></strong> <p>`; |
| 50 | + setInterval(() => { |
| 51 | + const timeUntilDate = response - (new Date()) |
| 52 | + let htmlToApply = formatTime(timeUntilDate); |
| 53 | + document.getElementById("fritid").innerText = htmlToApply; |
| 54 | + }, 1000) |
59 | 55 | }
|
| 56 | + |
| 57 | + const location = window.location.href; |
| 58 | + fGetXML(location?.split("/")?.[4], location?.split("?elevid=")?.[1]?.split("&")[0] ?? location?.split("&elevid=")?.[1]?.split("&")?.[0]); |
60 | 59 | })
|
61 | 60 |
|
62 |
| - chrome.storage.local.get(["antiAFK"], (result) => { |
63 |
| - if (result.antiAFK) { |
64 |
| - setInterval(() => { |
65 |
| - const afkAlert = document.querySelector("div.ui-dialog.ui-corner-all.ui-widget") |
66 |
| - if (afkAlert != null){ |
67 |
| - window.location.reload() |
68 |
| - } |
69 |
| - }, 5000) |
70 |
| - } |
| 61 | + getSetting("Anti AFK").then(isEnabled => { |
| 62 | + if (!isEnabled) return |
| 63 | + setInterval(() => { |
| 64 | + const afkAlert = document.querySelector("div.ui-dialog.ui-corner-all.ui-widget") |
| 65 | + if (afkAlert != null){ |
| 66 | + window.location.reload() |
| 67 | + } |
| 68 | + }, 5000) |
71 | 69 | })
|
72 | 70 | first(".lectioToolbar .floatLeft", e => {
|
73 | 71 | const btn = document.createElement("div")
|
|
0 commit comments