-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script for Feide to automatically choose microsoft after 5 sec
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| })(); |