45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
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
|