diff --git a/patches.json b/patches.json index 31c158e..665d3c7 100644 --- a/patches.json +++ b/patches.json @@ -353,5 +353,14 @@ "css": ["patchesSettings/style.css"] }, "allowedHostsCss": ["uczen.eduvulcan.pl", "dziennik-uczen.vulcan.net.pl", "wiadomosci.eduvulcan.pl", "dziennik-wiadomosci.vulcan.net.pl"] + }, + { + "name": "Excuse all button", + "description": "Adds option to select all the attendance to excuse with one click", + "files": { + "js": ["excuseAll/index.js"], + "css": ["excuseAll/styles.css"] + }, + "allowedHostsCss": ["uczen.eduvulcan.pl", "dziennik-uczen.vulcan.net.pl"] } ] \ No newline at end of file diff --git a/patches/excuseAll/index.js b/patches/excuseAll/index.js new file mode 100644 index 0000000..f237c19 --- /dev/null +++ b/patches/excuseAll/index.js @@ -0,0 +1,45 @@ +const run = () => { + const observer = new MutationObserver(() => { + const modalBody = document.querySelector(".modal__horizontal__group") + if (!modalBody || modalBody.querySelector(".excuse-all")) return + + const element = document.createElement("label"); + element.classList.add("excuse-all"); + element.innerHTML = ` + + + + + + + + + Usprawiedliw wszystko + ` + + element.querySelector("input").addEventListener("change", () => { + const isEnabled = element.querySelector("input").checked; + document.querySelectorAll("input[aria-label=\"Usprawiedliw\"]") + .forEach((i) => { + if(i.checked !== isEnabled) i.click() + }) + }) + + modalBody.insertBefore(element, modalBody.firstChild) + }) + + observer.observe(document.body, { + childList: true + }) +} + + +window.appendModule({ + onlyOnReloads: true, + run: run, + doesRunHere: () => window.location.href.includes("frekwencja") +}); \ No newline at end of file diff --git a/patches/excuseAll/styles.css b/patches/excuseAll/styles.css new file mode 100644 index 0000000..3ec36c0 --- /dev/null +++ b/patches/excuseAll/styles.css @@ -0,0 +1,11 @@ +.excuse-all:has(input:checked) .unchecked { + display: none; +} + +.excuse-all:has(input:not(:checked)) .checked { + display: none; +} + +.excuse-all .checked { + fill: rgb(225, 45, 57); +} \ No newline at end of file