From a30f11a9ebe274abc8eb3d53c98f59f775acfada Mon Sep 17 00:00:00 2001 From: Tobia5H Date: Tue, 23 Jan 2024 10:29:56 +0100 Subject: [PATCH 1/3] Add implementation for autoGoToLVA and autoGoToSemester --- tiss_quick_registration_script.user.js | 124 +++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 10 deletions(-) diff --git a/tiss_quick_registration_script.user.js b/tiss_quick_registration_script.user.js index 6fc0156..55ce495 100755 --- a/tiss_quick_registration_script.user.js +++ b/tiss_quick_registration_script.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name TISS Quick Registration Script // @namespace http://www.manuelgeier.com/ -// @version 1.6.3 +// @version 1.6.4 // @description Script to help you to get into the group you want. Opens automatically the right panel, registers automatically and confirms your registration automatically. If you don't want the script to do everything automatically, the focus is already set on the right button, so you only need to confirm. There is also an option available to auto refresh the page, if the registration button is not available yet, so you can open the site and watch the script doing its work. You can also set a specific time when the script should reload the page and start. // @match https://tiss.tuwien.ac.at/* // @copyright 2012+, Manuel Geier, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -10,6 +10,11 @@ /* Changelog: + + v.1.6.4 [23.01.2024] + + Added: autoGoToLVA support + + Added: autoGoToSemester support + (Greetings ~ Tobia5H :) ) v.1.6.3 [18.12.2020] + Added: date of exam support @@ -77,36 +82,39 @@ scriptEnabled: true, // define here the type of registration [lva,group,exam] - registrationType: "group", + registrationType: "exam", // name of you the group you want to join (only for registrationType 'group') [String] - nameOfGroup: "Gruppe 001", + nameOfGroup: "JK Kellner", // name of the exam which you want to join (only for registrationType 'exam') [String] - nameOfExam: "Name Of Exam", + nameOfExam: "Mündliche Prüfung", // date of the exam which you want to join, especially when there are multiple exams with the same name (only for registrationType 'exam') [String] - dateOfExam: '', + dateOfExam: '06.03.2024', // checks if you are at the correct lva page lvaCheckEnabled: true, // only if the number is right, the script is enabled [String] - lvaNumber: "123.456", + lvaNumber: "193.018", // if you have multiple study codes, enter here the study code number you want // to register for eg. '123456' (no blanks). Otherwise leave empty. [String] studyCode: '', - // autoGoToLVA: true, // coming soon + autoGoToLVA: false, // If you want to navigate automatically to the latest LVA-MAIN page, set this option to true. + // You need to set 'lvaNumber'!!! + // checks if you are at the correct semester lvaSemesterCheckEnabled: true, // only if the semester is right, the script is enabled [String] - lvaSemester: "2019W", + lvaSemester: "2023W", - // autoGoToSemester: true, // coming soon + autoGoToSemester: true, // If you want to navigate automatically to the LVA/Exam/Group/page with the specified Semester, set this option to true. + // You need to set 'lvaNumber' and 'lvaSemester'!!! // automatically opens the detail panel of a group [true,false] openPanel: true, @@ -136,7 +144,7 @@ // define the specific time the script should start [Date] // new Date(year, month, day, hours, minutes, seconds, milliseconds) // note: months start with 0 - specificStartTime: new Date(2020, 1 - 1, 9, 20, 27, 0, 0), + specificStartTime: new Date(2024, 1 - 1, 23, 12, 0, 0, 0), // if a specific time is defined, the script will refresh some ms sooner to adjust a delay [Integer] delayAdjustmentInMs: 300, @@ -167,6 +175,34 @@ self.tissQuickRegistration = function () { if (options.scriptEnabled) { + if (options.autoGoToLVA && options.autoGoToSemester) { + // Check if options.lvaNumber and options.lvaSemester are set + alert("Option 'autoGoToLVA' and 'autoGoToSemester' are both set to 'true'.\nPlease set at least one of them to 'false'."); + console.error("Option 'autoGoToLVA' and 'autoGoToSemester' are both set to 'true'. Please set at least one of them to 'false'."); + } + + if (options.autoGoToLVA && !options.autoGoToSemester) { + // Check if options.lvaNumber and options.lvaSemester are set + if (!options.lvaNumber) { + alert("Option 'lvaNumber' must be set for navigation."); + console.error("Options 'lvaNumber' must be set for navigation."); + return; + } else { + self.navigateToLVA(); + } + } + + if (options.autoGoToSemester && !options.autoGoToLVA) { + // Check if options.lvaNumber and options.lvaSemester are set + if (!options.lvaNumber || !options.lvaSemester) { + alert("Options 'lvaNumber' and 'lvaSemester' must be set for navigation."); + console.error("Options 'lvaNumber' and 'lvaSemester' must be set for navigation."); + return; + } else { + self.navigateToSemester(); + } + } + self.pageLog("TISS Quick Registration Script enabled"); self.pageLog("LVA Number: " + self.getLVANumber()); self.pageLog("LVA Name: " + self.getLVAName()); @@ -660,6 +696,74 @@ self.getFormatedDate = function (date) { return "" + date.getDate() + "." + (date.getMonth() + 1) + "." + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + ":" + date.getMilliseconds(); }; + + self.navigateToSemester = function () { + + var specifiedURL = ''; + + if (options.registrationType === "lva") { + // URL for LVA registration type + specifiedURL = 'https://tiss.tuwien.ac.at/education/course/courseRegistration.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, '') + '&semester=' + options.lvaSemester; + console.log("Registration type is LVA"); + } else if (options.registrationType === "group") { + // URL for group registration type + specifiedURL = 'https://tiss.tuwien.ac.at/education/course/groupList.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, '') + '&semester=' + options.lvaSemester; + console.log("Registration type is Group"); + } else if (options.registrationType === "exam") { + // URL for exam registration type + specifiedURL = 'https://tiss.tuwien.ac.at/education/course/examDateList.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, '') + '&semester=' + options.lvaSemester; + console.log("Registration type is Exam"); + } else { + // URL for other or unknown registration types + // default to LVA main page + specifiedURL = 'https://tiss.tuwien.ac.at/course/educationDetails.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); + console.log("Unknown registration type"); + } + + + // Get the current URL's search parameters + var urlSearchParams = new URLSearchParams(window.location.search); + + // Check if the specified query parameters exist, and if true, delete them + if (urlSearchParams.has('dswid') && urlSearchParams.has('dsrid')) { + urlSearchParams.delete('dswid'); + urlSearchParams.delete('dsrid'); + } + + // Build the modified URL + var currentURL = window.location.origin + window.location.pathname + '?' + urlSearchParams.toString(); + + + // Check if the current page is not already the specified LVA page + if (currentURL !== specifiedURL) { + // Navigate to the LVA page + window.location.href = specifiedURL; + } + }; + + self.navigateToLVA = function () { + + var specifiedURL = 'https://tiss.tuwien.ac.at/course/educationDetails.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); + + // Get the current URL's search parameters + var urlSearchParams = new URLSearchParams(window.location.search); + + // Check if the specified query parameters exist, and if true, delete them + if (urlSearchParams.has('dswid') && urlSearchParams.has('dsrid')) { + urlSearchParams.delete('dswid'); + urlSearchParams.delete('dsrid'); + } + + // Build the modified URL + var currentURL = window.location.origin + window.location.pathname + '?' + urlSearchParams.toString(); + + // Check if the current page is not already the specified LVA page + if (currentURL !== specifiedURL) { + // Navigate to the LVA page + window.location.href = specifiedURL; + } + }; + self.log = function (message) { console.log(message); From b710deacc3cd4e5663e422b5b16914fcd93168d9 Mon Sep 17 00:00:00 2001 From: Tobia5H Date: Tue, 23 Jan 2024 10:34:00 +0100 Subject: [PATCH 2/3] Change options back to default --- tiss_quick_registration_script.user.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tiss_quick_registration_script.user.js b/tiss_quick_registration_script.user.js index 55ce495..8b6f7ba 100755 --- a/tiss_quick_registration_script.user.js +++ b/tiss_quick_registration_script.user.js @@ -82,30 +82,30 @@ scriptEnabled: true, // define here the type of registration [lva,group,exam] - registrationType: "exam", + registrationType: "group", // name of you the group you want to join (only for registrationType 'group') [String] - nameOfGroup: "JK Kellner", + nameOfGroup: "Gruppe 001", // name of the exam which you want to join (only for registrationType 'exam') [String] - nameOfExam: "Mündliche Prüfung", + nameOfExam: "Name Of Exam", // date of the exam which you want to join, especially when there are multiple exams with the same name (only for registrationType 'exam') [String] - dateOfExam: '06.03.2024', + dateOfExam: '', // checks if you are at the correct lva page lvaCheckEnabled: true, // only if the number is right, the script is enabled [String] - lvaNumber: "193.018", + lvaNumber: "123.456", // if you have multiple study codes, enter here the study code number you want // to register for eg. '123456' (no blanks). Otherwise leave empty. [String] studyCode: '', - autoGoToLVA: false, // If you want to navigate automatically to the latest LVA-MAIN page, set this option to true. - // You need to set 'lvaNumber'!!! - + // If you want to navigate automatically to the latest LVA-MAIN page, set this option to true. + // You need to set 'lvaNumber'! + autoGoToLVA: false, // checks if you are at the correct semester lvaSemesterCheckEnabled: true, @@ -113,8 +113,9 @@ // only if the semester is right, the script is enabled [String] lvaSemester: "2023W", - autoGoToSemester: true, // If you want to navigate automatically to the LVA/Exam/Group/page with the specified Semester, set this option to true. - // You need to set 'lvaNumber' and 'lvaSemester'!!! + // If you want to navigate automatically to the LVA/Exam/Group/page with the specified Semester, set this option to true. + // You need to set 'lvaNumber' and 'lvaSemester'! + autoGoToSemester: false, // automatically opens the detail panel of a group [true,false] openPanel: true, @@ -144,7 +145,7 @@ // define the specific time the script should start [Date] // new Date(year, month, day, hours, minutes, seconds, milliseconds) // note: months start with 0 - specificStartTime: new Date(2024, 1 - 1, 23, 12, 0, 0, 0), + specificStartTime: new Date(2020, 1 - 1, 9, 20, 27, 0, 0), // if a specific time is defined, the script will refresh some ms sooner to adjust a delay [Integer] delayAdjustmentInMs: 300, From 9597c521d17c4ea38b99db1992135d67b820926e Mon Sep 17 00:00:00 2001 From: Tobia5H Date: Tue, 3 Dec 2024 17:20:20 +0100 Subject: [PATCH 3/3] Fix misaligned url params semester and course number --- tiss_quick_registration_script.user.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tiss_quick_registration_script.user.js b/tiss_quick_registration_script.user.js index 8b6f7ba..7e9776f 100755 --- a/tiss_quick_registration_script.user.js +++ b/tiss_quick_registration_script.user.js @@ -1,5 +1,5 @@ // ==UserScript== -// @name TISS Quick Registration Script +// @name TISS Quick Registration Script PRO // @namespace http://www.manuelgeier.com/ // @version 1.6.4 // @description Script to help you to get into the group you want. Opens automatically the right panel, registers automatically and confirms your registration automatically. If you don't want the script to do everything automatically, the focus is already set on the right button, so you only need to confirm. There is also an option available to auto refresh the page, if the registration button is not available yet, so you can open the site and watch the script doing its work. You can also set a specific time when the script should reload the page and start. @@ -699,29 +699,29 @@ }; self.navigateToSemester = function () { - + var specifiedURL = ''; - + if (options.registrationType === "lva") { // URL for LVA registration type - specifiedURL = 'https://tiss.tuwien.ac.at/education/course/courseRegistration.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, '') + '&semester=' + options.lvaSemester; + specifiedURL = 'https://tiss.tuwien.ac.at/education/course/courseRegistration.xhtml?semester=' + options.lvaSemester + '&courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); console.log("Registration type is LVA"); } else if (options.registrationType === "group") { // URL for group registration type - specifiedURL = 'https://tiss.tuwien.ac.at/education/course/groupList.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, '') + '&semester=' + options.lvaSemester; + specifiedURL = 'https://tiss.tuwien.ac.at/education/course/groupList.xhtml?semester=' + options.lvaSemester + '&courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); console.log("Registration type is Group"); } else if (options.registrationType === "exam") { // URL for exam registration type - specifiedURL = 'https://tiss.tuwien.ac.at/education/course/examDateList.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, '') + '&semester=' + options.lvaSemester; + specifiedURL = 'https://tiss.tuwien.ac.at/education/course/examDateList.xhtml?semester=' + options.lvaSemester + '&courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); console.log("Registration type is Exam"); } else { // URL for other or unknown registration types // default to LVA main page - specifiedURL = 'https://tiss.tuwien.ac.at/course/educationDetails.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); - console.log("Unknown registration type"); + specifiedURL = 'https://tiss.tuwien.ac.at/course/educationDetails.xhtml?courseNr=' + options.lvaNumber.replace(/[^\d]/, ''); + console.log("Unknown registration type"); } - + // Get the current URL's search parameters var urlSearchParams = new URLSearchParams(window.location.search);