Skip to content

Commit

Permalink
Added script for Feide to automatically choose microsoft after 5 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Aug 26, 2024
1 parent 212942d commit 0253a6f
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions feide-microsoft.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ==UserScript==
// @name Feide - Auto-Press Microsoft Sign-In.
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic
// @version 1.0
// @description Automatically press the Microsoft sign-in button after a countdown, with options to cancel or trigger manually.
// @author Øyvind Nilsen (on@ntnu.no)
// @match https://idp.feide.no/simplesaml/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=feide.no
// @grant none
// ==/UserScript==

(function() {
'use strict';

const button = document.getElementById('microsoft-signin-button');
if (!button) return;

let countdown = 5;
let countdownInterval;

function updateButtonText() {
button.value = `Use work or school account (${countdown}s)`;
}

function startCountdown() {
updateButtonText();
countdownInterval = setInterval(() => {
countdown--;
if (countdown <= 0) {
clearInterval(countdownInterval);
button.click();
} else {
updateButtonText();
}
}, 1000);
}

function stopCountdown() {
clearInterval(countdownInterval);
button.value = 'Use work or school account';
}

document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
stopCountdown();
} else if (event.ctrlKey && event.key === 'Enter') {
clearInterval(countdownInterval);
button.click();
}
});

startCountdown();
})();

0 comments on commit 0253a6f

Please sign in to comment.