From a95dbeea795983a5eb8978089fea4d85d6bb87e6 Mon Sep 17 00:00:00 2001 From: Gaspard Jankowiak Date: Thu, 25 Sep 2025 10:05:10 +0200 Subject: [PATCH] fix support for waiting list pages --- directory.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/directory.js b/directory.js index 2875c4e..4c64824 100644 --- a/directory.js +++ b/directory.js @@ -127,14 +127,26 @@ function generateTrombi() { trombi.classList.add("kf-trombi_enhanced"); const form = $G("idTNListe"); - const table_body = $G("idTNVWTable").tBodies[0]; + const table = $G("idTNVWTable"); + const table_head_first_row = table.tHead.rows[0]; + const table_body = table.tBodies[0]; + + // check if the page is a waiting list (Warteliste) + // in which case columns are shifted because of the 'Pos' + // column. + + const isWaitingList = (table_head_first_row.children[1].textContent.trim() == "Pos"); + + const lastnameOffset = 1 + isWaitingList; + const fistnameOffset = 2 + isWaitingList; + const studentFileLinkOffset = 1 - isWaitingList; const student_list = []; for (let row of table_body.children) { student_list.push({ - lastname: row.children[1].textContent, - firstname: row.children[2].textContent, - ids: extractIDs(row.children[1].children[1].href) + lastname: row.children[lastnameOffset].textContent, + firstname: row.children[fistnameOffset].textContent, + ids: extractIDs(row.children[lastnameOffset].children[studentFileLinkOffset].href) }) };