Skip Microsoft 2FA

Skip Microsoft asking for 2fa

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Skip Microsoft 2FA
// @namespace    http://tampermonkey.net/
// @version      2025-01-24
// @description  Skip Microsoft asking for 2fa
// @author       Soggy_Pancake
// @match        *://*.microsoft.*/*
// @include      *://*.microsoft.*/*
// @include      *://*.microsoftonline.*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      GPLv3
// ==/UserScript==

var skipStaySignedIn = false;
var staySignedIn = true;

var scanSpeed = 200; // ms between scanning for elements

var timeoutID;

function moreInformationPage(){

    let heading = document.getElementById("heading");
    let text = document.getElements

    if(heading != null){

        console.log("Got heading!");
        console.log(heading);

        if(heading.textContent == "More information required"){

            let nextButton = document.getElementById("idSubmit_ProofUp_Redirect");

            nextButton.click();
            clearTimeout(timeoutID);

        }
    }
}

function authenticatorPopup(){

    let links = document.getElementsByClassName("ms-Link");

    if(links != null){

        //console.log(links);
        for(let i = 0; i < links.length; i++){
            //console.log(links[i]);

            if(links[i].textContent == "I want to use a different authenticator app"){

                for(let j = 0; j < links.length; j++){

                    if(links[j].textContent == "Skip setup"){

                        console.log(`buttons[{j}]`);

                        links[j].click();

                        clearTimeout(timeoutID);

                    }

                }

            }

        }

    }

}

function staySignedInPage(){

    let text = document.getElementsByClassName("text-title");

    if(text.length == 0){
        return;
    }

    //console.log("Skipping remember login!");
    //console.log(text);

    //console.log(`Found ${text.length} elements with class text-title`);
    for(let i = 0; i < text.length; i++){

        if(text[i].textContent == "Stay signed in?") {

            let button = null;

            if(staySignedIn){

                console.log("Staying signed in!");

                let dontShowAgain = document.getElementById("KmsiCheckboxField");
                dontShowAgain.checked = true;

                document.getElementById("idSIButton9").click();

            } else {

                console.log("Not staying signed in!");
                document.getElementById("idBtn_Back").click();

            }

        }

    }

}

function scan(){

    moreInformationPage();
    authenticatorPopup();

    if(skipStaySignedIn){
        staySignedInPage();
    }

    timeoutID = setTimeout(scan, scanSpeed);
}

(function() {
    'use strict';

    let host = window.location.hostname;

    host = host.substring(host.indexOf(".") + 1);

    console.log(host);
    if (host.includes("microsoft")) {

        scan();
    }

})();