import
This commit is contained in:
commit
3daa151896
1 changed files with 212 additions and 0 deletions
45
content.js
Normal file
45
content.js
Normal file
|
|
@ -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
|
||||
Loading…
Reference in a new issue