From a0f9f80d3425b6637fb364cc88b1638bef7e05c0 Mon Sep 17 00:00:00 2001 From: Luca <43651170+ronny17@users.noreply.github.com> Date: Wed, 19 Oct 2022 18:03:51 +0200 Subject: [PATCH] Added Uniparma login module --- sharedown/loginModules/UniParma.js | 58 +++++++++++++++++++++++++++ sharedown/loginModules/loginModule.js | 7 +++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 sharedown/loginModules/UniParma.js diff --git a/sharedown/loginModules/UniParma.js b/sharedown/loginModules/UniParma.js new file mode 100644 index 0000000..d3b1a72 --- /dev/null +++ b/sharedown/loginModules/UniParma.js @@ -0,0 +1,58 @@ +/** + * This file is part of the Sharedown (https://github.com/kylon/Sharedown). + * Copyright (c) 2021 Kylon. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +"use strict"; + +const basic = require('./Basic'); + +class UniParma extends basic.BasicLogin { + constructor() { + super(); + this.registerField('Email', basic.InputType.Text, 'Email provied by your university'); + this.registerField('Password', basic.InputType.Password); + } + + async doLogin(puppeteerPage, loginData) { + await puppeteerPage.waitForNavigation({waitUntil: 'networkidle2'}); + await puppeteerPage.waitForSelector('input[type="email"]'); + await puppeteerPage.focus('input[type="email"]'); + await puppeteerPage.evaluate(() => document.querySelector('input[type="email"]').value = ''); + await puppeteerPage.keyboard.type(loginData.field0); + await puppeteerPage.click('input[type="submit"]') + await puppeteerPage.waitForNavigation({waitUntil: 'networkidle2'}); + + await puppeteerPage.waitForSelector('input[id="userNameInput"]'); + await puppeteerPage.focus('input[id="userNameInput"]'); + await puppeteerPage.evaluate(() => document.querySelector('input[id="userNameInput"]').value = ''); + await puppeteerPage.keyboard.type(loginData.field0); + + await puppeteerPage.waitForSelector('input[id="passwordInput"]'); + await puppeteerPage.focus('input[id="passwordInput"]'); + await puppeteerPage.evaluate(() => document.querySelector('input[id="passwordInput"]').value = ''); + await puppeteerPage.keyboard.type(loginData.field1); + + await puppeteerPage.click('span[id="submitButton"]'); + await puppeteerPage.waitForNavigation({waitUntil: 'networkidle2'}); + + if ((await puppeteerPage.$('input[id="idBtn_Back"]')) !== null) { + await puppeteerPage.waitForSelector('input[id="idBtn_Back"]', {timeout: 6000}); + await puppeteerPage.focus('input[id="idBtn_Back"]'); + await puppeteerPage.click('input[id="idBtn_Back"]'); + } + } +} + +module.exports = UniParma; diff --git a/sharedown/loginModules/loginModule.js b/sharedown/loginModules/loginModule.js index 332740f..1f48f0d 100755 --- a/sharedown/loginModules/loginModule.js +++ b/sharedown/loginModules/loginModule.js @@ -20,6 +20,7 @@ const basic = require('./Basic'); const simpleUniversity = require('./SimpleUniversity'); const simpleUniversity365 = require('./SimpleUniversity365'); const unina = require('./Unina'); +const uniparma = require('./UniParma') class LoginModule { // Sharedown UI module label @@ -27,7 +28,8 @@ class LoginModule { 'Basic - Manual login', 'University [Simple]', 'University [MS 365]', - 'Unina' + 'Unina', + 'UniParma' ]; #active; @@ -48,6 +50,9 @@ class LoginModule { case 3: this.#active = new unina(); break; + case 4: + this.#active = new uniparma(); + break; default: this.#active = new basic.BasicLogin(); break;