User Setup Loop

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

ของเมื่อวันที่ 17-12-2018 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         User Setup Loop
// @namespace    localhost
// @version      0.1.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") {
        $("#enableUserLoop").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("<br>User Loop Enabled? <input type= 'checkbox' id= 'enableUserLoop' value= 'enableUserLoop'>");
        //("<button id='startUserLoopBtn' type='button'><font color='black'>Start User Setup Loop</font></button>");
        $("#enableUserLoop").click(function(){
            if ($("#enableUserLoop").prop("checked") == true) {
                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();
            } else {
            }
        });
    }
}




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


    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")) {
        userLoopStatus = "y";
        localStorage.setItem("userLoopStatus", userLoopStatus);
        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";
                    userLoopStatus = "y";
                    localStorage.getItem("userLoopStatus", userLoopStatus);
                    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();
        }
    });
}