Skip to content

Instantly share code, notes, and snippets.

@VaiTon
Created January 1, 2022 01:18
Show Gist options
  • Save VaiTon/35af040b965a4c8b0a1adb29ebca8b1c to your computer and use it in GitHub Desktop.
Save VaiTon/35af040b965a4c8b0a1adb29ebca8b1c to your computer and use it in GitHub Desktop.
Chromium userscript for UniBo IDP autologin
// ==UserScript==
// @name UniBo AutoLogin
// @description AutoLogin to UniBo IDP by using saved passwords
// @version 0.1.0
// @author VaiTon <[email protected]>
// @match https://idp.unibo.it/adfs/ls/*
// @match https://shib.unibo.it/idp/*
// @icon https://www.google.com/s2/favicons?domain=unibo.it
// @grant none
// ==/UserScript==
(function () {
'use strict';
if (window.HRD) {
// Select UniBo
window.HRD.selection('AD AUTHORITY');
return;
}
let loginForm = document.forms.loginForm;
if (loginForm && window.PasswordCredential) {
navigator.credentials.get({ password: true }).then((cred) => {
// Login through the browser identity manager
loginForm.elements.userNameInput.value = cred.id;
loginForm.elements.passwordInput.value = cred.password;
loginForm.submit();
});
return;
}
if (document.location.origin === 'https://shib.unibo.it') {
let loginForm = document.forms[0];
navigator.credentials.get({ password: true }).then((cred) => {
loginForm.elements.j_username.value = cred.id;
loginForm.elements.j_password.value = cred.password;
loginForm.elements._eventId_proceed.click()
});
return;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment