diff --git a/feide-microsoft.user.js b/feide-microsoft.user.js new file mode 100644 index 0000000..194de71 --- /dev/null +++ b/feide-microsoft.user.js @@ -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(); +})(); \ No newline at end of file