User Setup Loop

This script is a companion script to run with the "Installz Script"

17.12.2018 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         User Setup Loop
// @namespace    localhost
// @version      0.1
// @description  This script is a companion script to run with the "Installz Script"
// @author       [email protected]
// @include     *autoloop.us*
// @grant        none
// @icon
// ==/UserScript==
'use strict';
if ((window.location.href == ('https://autoloop.us/DMS/App/DealershipSettings/UserManagement.aspx')) || (window.location.href == ('https://autoloop.us/DMS/App/DealershipSettings/UserManagement.aspx#!'))) {
    var userLoopStatus = localStorage.getItem("userLoopStatus");

    if (userLoopStatus == "y") {
        $("[data-tip='Add New User']").click();
        UserManagementHomePage()

    } else if (userLoopStatus == "n") {
        alert("User Setup Complete \n\nNOTE: Remember to disable the User Loop!")
        UserManagementHomePage()

    } else {
        UserManagementHomePage()
    }

    function UserManagementHomePage() {
        $("pre").append("<button id='startUserLoopBtn' type='button'><font color='black'>Start User Setup Loop</font></button>");
        $("#startUserLoopBtn").click(function(){
            var userGraveyardSet = ""
            var pageWaitStatusLoop = "n";
            var completeUserStatus = "n";
            var userLoopStatus = "y";
            var usersAdded = "";
            localStorage.setItem("userGraveyard", userGraveyardSet);
            localStorage.setItem("userLoopStatus", userLoopStatus);
            localStorage.setItem("pageWaitStatusLoop", pageWaitStatusLoop);
            localStorage.setItem("completeUserStatus", completeUserStatus);
            localStorage.setItem("usersAdded", usersAdded); //store "n" so that this code only runs when it is supposed to
            $("[data-tip='Add New User']").click();
        });
    }
}




if (window.location.href == ('https://autoloop.us/DMS/App/DealershipSettings/EditUser.aspx')) {
    var completeUserStatus = localStorage.getItem("completeUserStatus");


    if ($(".notificationError .messageContents").text().includes("There was a problem with your submission.That Username already exists in the system. Either choose a different Username or add this User from the Add Existing User screen.Show Errors")) {
        var existingUserEmail = $("[name='ctl00\$ctl00\$Main\$Main\$tfEmailAddress\$textBox']").val();
        localStorage.setItem("existingUserEmail", existingUserEmail);
        window.location.href = "https://autoloop.us/DMS/App/DealershipSettings/AddExistingUser.aspx"
    } else {

        if (completeUserStatus == "n") {
            function UserSetup() {
                var settingsString = localStorage.getItem("settingsKeyStorage"); //get stored settings key from user management home page
                var parsedSettingsString = settingsString.split('~'); //settings key parsed, using '~' as delimiter
                var userGraveyard = localStorage.getItem("userGraveyard"); //get stored settings key from user management home page
                var usersAdded = localStorage.getItem("usersAdded"); //store "n" so that this code only runs when it is supposed to

                var UserItemNumbers = {
                    "salesUser1" : parsedSettingsString[144],
                    "salesUser2" : parsedSettingsString[145],
                    "salesUser3" : parsedSettingsString[146],
                    "salesUser4" : parsedSettingsString[147],
                    "salesUser5" : parsedSettingsString[148],
                    "salesUser6" : parsedSettingsString[149],
                    "salesUser7" : parsedSettingsString[150],
                    "salesUser8" : parsedSettingsString[151],
                    "salesUser9" : parsedSettingsString[152],
                    "salesUser10" : parsedSettingsString[153],

                    "serviceUser1" : parsedSettingsString[154],
                    "serviceUser2" : parsedSettingsString[155],
                    "serviceUser3" : parsedSettingsString[156],
                    "serviceUser4" : parsedSettingsString[157],
                    "serviceUser5" : parsedSettingsString[158],
                    "serviceUser6" : parsedSettingsString[159],
                    "serviceUser7" : parsedSettingsString[160],
                    "serviceUser8" : parsedSettingsString[161],
                    "serviceUser9" : parsedSettingsString[162],
                    "serviceUser10" : parsedSettingsString[163],
                }


                for (var user in UserItemNumbers) {
                    var currentUser = UserItemNumbers[user];
                    var userGraveyardArray = userGraveyard.split(">");
                    var findUserStatus = "n";
                    var matchCounter = 0;
                    var userLoopStatus = localStorage.getItem("userLoopStatus");

                    /*if (usersAdded.split("~").length >= 11) {
                        //go to home page
                        userLoopStatus = "n";
                        localStorage.setItem("userLoopStatus", userLoopStatus);
                        alert("go to home page")

                    } else*/ if (usersAdded.includes(user) == true) {
                        //do nothing

                    } else {
                        for (var i = 0; i < userGraveyardArray.length; i++) {
                            if ((userGraveyardArray[i] == currentUser)  && (currentUser !== "") || (currentUser == "")) { //(userGraveyardArray[i] !== currentUser) {
                                matchCounter++;
                            }
                        }

                        if (currentUser == "*") {
                            usersAdded += "~" + user;
                            //alert(usersAdded)
                            localStorage.setItem("usersAdded", usersAdded); //set local variable "userGraveyard"

                        } else if (matchCounter <= 0) {
                            usersAdded += "~" + user;
                            //alert(usersAdded)
                            localStorage.setItem("usersAdded", usersAdded); //set local variable "userGraveyard"
                            doo();
                            break;

                        } else if (matchCounter >= 1) {
                            //usersAdded += "~" + user;
                            alert(usersAdded)
                            localStorage.setItem("usersAdded", usersAdded); //set local variable "userGraveyard"
                        }

                    }

                    if (usersAdded.split("~").length >= 21) {
                        userLoopStatus = "n";
                        localStorage.setItem("userLoopStatus", userLoopStatus);
                        window.location.href = "https://autoloop.us/DMS/App/DealershipSettings/UserManagement.aspx";
                    }
                }

                function doo() {
                    findUserStatus = "y";
                    var userGraveyardPlus = userGraveyard + ">" + currentUser;
                    completeUserStatus = "y";
                    localStorage.setItem("userGraveyard", userGraveyardPlus); //set local variable "userGraveyard"
                    localStorage.setItem("completeUserStatus", completeUserStatus); //set local variable "completeUserStatus"
                    currentUser = currentUser.split("*");
                    $("[placeholder]").val(currentUser[0].trim());
                    $("#executeButton").click();
                }
            }
            UserSetup()

        } else if (completeUserStatus == "y") {
            completeUserStatus = "n";
            localStorage.setItem("completeUserStatus", completeUserStatus); //set local variable "completeUserStatus"
            $("[onkeypress] > div:nth-of-type(4) .GeneratedButtonLink:nth-of-type(1)").click();
        }
    }
}




if (window.location.href == ('https://autoloop.us/DMS/App/DealershipSettings/AddExistingUser.aspx')) {

    $(window).load(function() {
        if ($("#ctl00_ctl00_MasterPageBodyTag > div.barWrapper > div.notificationSuccess.notificationMessage > div > ul > li").text().includes(" to this Company.  You can add more users, return to your company's settings screen or Edit ")) {
            window.location.href = "https://autoloop.us/DMS/App/DealershipSettings/UserManagement.aspx"
        } else {
            var existingUserEmail = localStorage.getItem("existingUserEmail");
            $("[name='ctl00\$ctl00\$Main\$Main\$tfUserName\$textBox']").val(existingUserEmail);
            $("[onkeypress] div .GeneratedButtonLink:nth-of-type(2)").click();
        }
    });
}