commit 3daa151896e813c9cff7849611981c6dce69d441 Author: Gaspard Jankowiak Date: Wed Oct 28 12:26:31 2026 +0100 import diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a9af754 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +VERSION = $(shell sed -n '/"version"/s/.*\"\([0-9.]\+\)\",/\1/p' manifest.json) +SET_VERSION = $(eval CURRENT_VERSION=$(VERSION)) + +default: v2 + +v2: + $(SET_VERSION) + zip -r releases/kf-better-ugo-$(CURRENT_VERSION).xpi content.css content.js icons manifest.json common.js diff --git a/common.js b/common.js new file mode 100644 index 0000000..6d6cf13 --- /dev/null +++ b/common.js @@ -0,0 +1,39 @@ +const Common = {}; + +const HTTPP = document.location.protocol + "//" + document.location.host; + +var currentGroupName = ""; + +// helpers +const $C = (e, opts = {}) => { + const elem = document.createElement(e); + for (const key in opts) { + if (key == "classList") { + const cl = opts[key]; + if (typeof (cl) == "string") { + elem.classList.add(cl); + } else { + elem.classList.add(...cl); + } + continue; + } else if (key == "children") { + elem.append(...opts[key]); + continue; + } else if (key == "title") { + elem.setAttribute(key, opts[key]); + continue; + } + elem[key] = opts[key]; + } + return elem; +} + +const $G = (e) => document.getElementById(e); + +const $S = (s) => document.querySelector(s); + +Common.$G = $G; +Common.$C = $C; +Common.initializeModal = initializeModal; + +// vim: ts=2 sts=2 sw=2 diff --git a/content.css b/content.css new file mode 100644 index 0000000..0be3993 --- /dev/null +++ b/content.css @@ -0,0 +1,4 @@ +.kf-groups-quick-link { + margin-left: 0.2em; + font-size: 1.3em; +} diff --git a/content.js b/content.js new file mode 100644 index 0000000..d36e3af --- /dev/null +++ b/content.js @@ -0,0 +1,45 @@ +const UGOpp = {}; + +const __kf_course_id_regex = /[0-9]+$/; + +function _injectQuickLinks() { + const table = Common.$G("idLVOfferTab") + if (table?.querySelector(".kf-groups-quick-link")) return; + + const rows = table.querySelectorAll("tr.hi"); + + rows.forEach((row) => { + const tds = row.querySelectorAll("td") + const mainLink = tds[3].querySelector("a"); + const courseId = mainLink.href.match(__kf_course_id_regex)[0]; + const link = Common.$C("a", {classList: "kf-groups-quick-link", href:`https://online.uni-graz.at/kfu_online/sa.gruppen_einteilung?cLvNr=${courseId}`, children:["👥"]}) + tds[2].append(link) + }) +} + +function injectQuickLinks() { + const observerOptions = { + childList: true, + subtree: true, + }; + + const observer = new MutationObserver(logChanges) + observer.observe(document.body, observerOptions); +} + +function logChanges(records, observer) { + for (const record of records) { + for (const addedNode of record.addedNodes) { + if (addedNode.id == "actions") { + observer.disconnect(); + _injectQuickLinks(); + } + } + } +} + +UGOpp.injectQuickLinks = injectQuickLinks; + +injectQuickLinks(); + +// vim: ts=2 sts=2 sw=2 diff --git a/icons/icon-128-padded.png b/icons/icon-128-padded.png new file mode 100644 index 0000000..a356d90 Binary files /dev/null and b/icons/icon-128-padded.png differ diff --git a/icons/icon.svg b/icons/icon.svg new file mode 100644 index 0000000..cd0721c --- /dev/null +++ b/icons/icon.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + UGO + + ++ + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..7cfa430 --- /dev/null +++ b/manifest.json @@ -0,0 +1,31 @@ +{ + "manifest_version": 2, + "name": "KF-UGO++", + "version": "0.0.1", + "browser_specific_settings": { + "gecko": { + "id": "kf-ugopp@math.janko.fr", + "data_collection_permissions": { + "required": ["none"] + } + } + }, + "description": "Collection of small improvements for online.uni-graz.at", + "icons": { + "128": "icons/icon-128-padded.png" + }, + "content_scripts": [ + { + "matches": [ + "https://online.uni-graz.at/kfu_online/wblvangebot.wbshowlvoffer" + ], + "js": [ + "common.js", + "content.js" + ], + "css": [ + "content.css" + ] + } + ] +}