From 0253a6f0b6b4dcbc3cfb1c5a5166c18d3bc7a58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Andreas=20Nilsen?= Date: Mon, 26 Aug 2024 09:27:17 +0200 Subject: [PATCH] Added script for Feide to automatically choose microsoft after 5 sec --- feide-microsoft.user.js | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 feide-microsoft.user.js 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