Skip to content

Instantly share code, notes, and snippets.

@SpaceSaver
Created September 2, 2025 04:26
Show Gist options
  • Save SpaceSaver/9401a1a4bd7ea6840b300c9833b2e0c7 to your computer and use it in GitHub Desktop.
Save SpaceSaver/9401a1a4bd7ea6840b300c9833b2e0c7 to your computer and use it in GitHub Desktop.
Automatically Login to Microsoft Account
// ==UserScript==
// @name MS Automatic Login
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Automates login to Microsoft corporate accounts (including education)
// @author @SpaceSaver2000
// @match https://login.microsoftonline.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=office.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const EMAIL = "YOUR_EMAIL_HERE";
const PASS = "YOUR_PASSWORD_HERE";
setInterval(() => {
const emailSelection = document.querySelector("input[type=\"email\"]");
const continueSelection = document.querySelector("input[type=\"submit\"]");
const passSelection = document.querySelector("input[type=\"password\"]");
const stayLogged = document.querySelector("#idSIButton9");
if (emailSelection && emailSelection.value == ""){
emailSelection.value = EMAIL;
} else if (emailSelection && emailSelection.value !== "" && continueSelection) {
continueSelection.focus();
continueSelection.click();
} else if (passSelection && passSelection.value == "") {
passSelection.value = PASS;
} else if (passSelection && passSelection.value !== "" && continueSelection) {
continueSelection.focus();
continueSelection.click();
} else if (stayLogged) {
stayLogged.click();
}
}, 500)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment