kalpdev.1 / Project Eliminator

// ==UserScript==
// @name         Project Eliminator
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Identifies incorrect inputs from TT page
// @author       regcat-sde@
// @license MIT
// @match        https://*.tt.amazon.com/*
// @match        https://tt.amazon.com/*
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.es6.min.js
// @require      https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js
// @require      https://unpkg.com/sweetalert/dist/sweetalert.min.js
// ==/UserScript==

function testAlert(){
    $("#save-button").before('<a class="tt_button orange_button" id="check-button"><span>Save</span></a>');
    $("#save-button").hide();
    $("#tabstrip").after('<br><br><button id="Error_count" class="a-button-text" type="button">Show Error Count</button>');

                                $('#Error_count').click(function(event) {
                                                var cndtn1_err_cnt = localStorage.getItem("condition1_errorcount");
            var cndtn2_err_cnt = localStorage.getItem("condition2_errorcount");
            var cndtn3_err_cnt = localStorage.getItem("condition3_errorcount");
            var cndtn4_err_cnt = localStorage.getItem("condition4_errorcount");
            var cndtn5_err_cnt = localStorage.getItem("condition5_errorcount");
                                                var cndtn6_err_cnt = localStorage.getItem("condition6_errorcount");
            var cndtn7_err_cnt = localStorage.getItem("condition7_errorcount");
            var cndtn8_err_cnt = localStorage.getItem("condition8_errorcount");
            var cndtn9_err_cnt = localStorage.getItem("condition9_errorcount");
            var cndtn10_err_cnt = localStorage.getItem("condition10_errorcount");
            var cndtn11_err_cnt = localStorage.getItem("condition11_errorcount");
            var cndtn12_err_cnt = localStorage.getItem("condition12_errorcount");
            var cndtn13_err_cnt = localStorage.getItem("condition13_errorcount");
            var cndtn14_err_cnt = localStorage.getItem("condition14_errorcount");
            var cndtn15_err_cnt = localStorage.getItem("condition15_errorcount");
            var cndtn16_err_cnt = localStorage.getItem("condition16_errorcount");
            var cndtn17_err_cnt = localStorage.getItem("condition17_errorcount");
            var cndtn18_err_cnt = localStorage.getItem("condition18_errorcount");
            var cndtn19_err_cnt = localStorage.getItem("condition19_errorcount");
            var cndtn20_err_cnt = localStorage.getItem("condition20_errorcount");
            var cndtn21_err_cnt = localStorage.getItem("condition21_errorcount");
            var cndtn22_err_cnt = localStorage.getItem("condition22_errorcount");
            //var cndtn23_err_cnt = localStorage.getItem("condition23_errorcount");

                                                cndtn1_err_cnt = (cndtn1_err_cnt == null) ? 0 : cndtn1_err_cnt;
                                                cndtn2_err_cnt = (cndtn2_err_cnt == null) ? 0 : cndtn2_err_cnt;
                                                cndtn3_err_cnt = (cndtn3_err_cnt == null) ? 0 : cndtn3_err_cnt;
                                                cndtn4_err_cnt = (cndtn4_err_cnt == null) ? 0 : cndtn4_err_cnt;
                                                cndtn5_err_cnt = (cndtn5_err_cnt == null) ? 0 : cndtn5_err_cnt;
                                                cndtn6_err_cnt = (cndtn6_err_cnt == null) ? 0 : cndtn6_err_cnt;
                                                cndtn7_err_cnt = (cndtn7_err_cnt == null) ? 0 : cndtn7_err_cnt;
                                                cndtn8_err_cnt = (cndtn8_err_cnt == null) ? 0 : cndtn8_err_cnt;
                                                cndtn9_err_cnt = (cndtn9_err_cnt == null) ? 0 : cndtn9_err_cnt;
                                                cndtn10_err_cnt = (cndtn10_err_cnt == null) ? 0 : cndtn10_err_cnt;
                                                cndtn11_err_cnt = (cndtn11_err_cnt == null) ? 0 : cndtn11_err_cnt;
                                                cndtn12_err_cnt = (cndtn12_err_cnt == null) ? 0 : cndtn12_err_cnt;
                                                cndtn13_err_cnt = (cndtn13_err_cnt == null) ? 0 : cndtn13_err_cnt;
                                                cndtn14_err_cnt = (cndtn14_err_cnt == null) ? 0 : cndtn14_err_cnt;
                                                cndtn15_err_cnt = (cndtn15_err_cnt == null) ? 0 : cndtn15_err_cnt;
                                                cndtn16_err_cnt = (cndtn16_err_cnt == null) ? 0 : cndtn16_err_cnt;
                                                cndtn17_err_cnt = (cndtn17_err_cnt == null) ? 0 : cndtn17_err_cnt;
                                                cndtn18_err_cnt = (cndtn18_err_cnt == null) ? 0 : cndtn18_err_cnt;
                                                cndtn19_err_cnt = (cndtn19_err_cnt == null) ? 0 : cndtn19_err_cnt;
                                                cndtn20_err_cnt = (cndtn20_err_cnt == null) ? 0 : cndtn20_err_cnt;
                                                cndtn21_err_cnt = (cndtn21_err_cnt == null) ? 0 : cndtn21_err_cnt;
                                                cndtn22_err_cnt = (cndtn22_err_cnt == null) ? 0 : cndtn22_err_cnt;
                                                //cndtn23_err_cnt = (cndtn23_err_cnt == null) ? 0 : cndtn23_err_cnt;

                                                swal({
                                                                title: "Error Count",
                                                                  text: "ASIN not entered :  " + cndtn1_err_cnt + "\nIncorrect FC blurb :  " + cndtn2_err_cnt + "\nIncorrect Non FC blurb :  " + cndtn3_err_cnt + "\nMaster Ticket ID not entered :  " + cndtn4_err_cnt + "\nShipping Name not entered :  " + cndtn5_err_cnt + "\nCLP Category not removed :  " + cndtn6_err_cnt + "\nRetail Blurb not used :  " + cndtn7_err_cnt + "\nSeller Support/FBA Blurb not used :  " + cndtn8_err_cnt +  "\nNon-DG blurb not used for Unregulated Exceptions :  " + cndtn9_err_cnt + "\nTranship line not removed :  " + cndtn10_err_cnt + "\nUS Blurb not used for US MP :  " + cndtn11_err_cnt + "\nUK Blurb not used for UK MP :  " + cndtn12_err_cnt + "\nCA Blurb not used for CA MP :  " + cndtn13_err_cnt + "\nIN Blurb not used for IN MP :  " + cndtn14_err_cnt + "\nSelect based on the reason keyword in blurb :  " + cndtn15_err_cnt + "\nVendor code not entered :  " + cndtn16_err_cnt + "\nParagon case link not entered :  " + cndtn17_err_cnt + "\nSeller id not entered :  " + cndtn18_err_cnt + "\nChoose either sds or ES Blurb not amended :  " + cndtn19_err_cnt + "\nChoose as applicable Blurb not amended :  " + cndtn20_err_cnt + "\nIncomplete or inaccurate or conflicting Blurb not amended :  " + cndtn21_err_cnt + "\nSelect based on the reason Blurb not amended :  " + cndtn22_err_cnt,
                                                                button: "OK"
                                                });
                                });

    $('#check-button').click(function(event) {

        var correspondence_text = document.getElementById('correspondence').value;
                                var lowercase_string_check = correspondence_text.toLowerCase();
        var item_value = document.getElementById('item').value;
        var type = document.getElementById('type').value;
        var pending_reason = document.getElementById('original_ticket_pending_reason').value;
        var rootCause = document.getElementById('original_ticket_root_cause').value;
        var tt_title = document.getElementById('details').value;
                                var lowercase_title = tt_title.toLowerCase();
        var short_description = document.getElementById('short_description').value;
        var lowercase_description = short_description.toLowerCase();
        var flag = 0;

        var error_msg1 = "";
        var error_msg2 = "";
        var error_msg3 = "";
        var error_msg4 = "";
        var error_msg5 = "";
        var error_msg6 = "";
        var error_msg7 = "";
        var error_msg8 = "";
        var error_msg9 = "";
        var error_msg10 = "";
        var error_msg11 = "";
        var error_msg12 = "";
        var error_msg13 = "";
        var error_msg14 = "";
        var error_msg15 = "";
        var error_msg16 = "";
        var error_msg17 = "";
        var error_msg18 = "";
        var error_msg19 = "";
        var error_msg20 = "";
        var error_msg21 = "";
        var error_msg22 = "";
        var error_msg23 = "";


                                //condition 1
                                if(lowercase_string_check.includes("insert asin")==true)
                                {
            error_msg1 = "ASIN not entered. Please Enter the ASIN\n";
            flag= 1;
                                                if             (localStorage.getItem("condition1_errorcount") === null) {
                                                                                localStorage.setItem("condition1_errorcount", 1);                            }
                                                else{      localStorage.condition1_errorcount = Number(localStorage.condition1_errorcount) + 1;            }
                                }

                                //condition 2
        if((item_value=="FC Inbound Issue" || item_value=="FC Outbound issue") && (lowercase_string_check.includes("resolving. please re-open if needed")==true))
                                {
            error_msg2 = "Incorrect FC blurb\n";
            flag= 1;
                                                if             (localStorage.getItem("condition2_errorcount") === null) {
                                                                                localStorage.setItem("condition2_errorcount", 1);                            }
                                                else{      localStorage.condition2_errorcount = Number(localStorage.condition2_errorcount) + 1;            }
                                }

                                //condition 3
        if((item_value=="ASIN Review Request: Seller Support Group" || item_value=="ASIN Review Request Retail Group" || item_value=="ASIN Review Request: Retail/CS Group" || item_value=="ASIN Review Request: Retail Group" || item_value=="ASIN Review Request: FBA Group") && lowercase_string_check.includes("please receive / stow / ship")==true)
        {
            error_msg3 = "Incorrect Non FC blurb\n";
            flag= 1;
                                                if             (localStorage.getItem("condition3_errorcount") === null) {
                                                                                localStorage.setItem("condition3_errorcount", 1);                            }
                                                else{      localStorage.condition3_errorcount = Number(localStorage.condition3_errorcount) + 1;            }
        }

                                //condition 4
                                if(lowercase_string_check.includes("insert master ticket id")==true)
                                {
            error_msg4 = "Master Ticket ID not entered\n";
            flag= 1;
                                                if             (localStorage.getItem("condition4_errorcount") === null) {
                                                                                localStorage.setItem("condition4_errorcount", 1);                            }
                                                else{      localStorage.condition4_errorcount = Number(localStorage.condition4_errorcount) + 1;            }
                                }

                                //condition 5
                                if(lowercase_string_check.includes("insert shipping name")==true)
                                {
            error_msg5 = "Shipping Name not entered\n";
            flag= 1;
                                                if             (localStorage.getItem("condition5_errorcount") === null) {
                                                                                localStorage.setItem("condition5_errorcount", 1);                            }
                                                else{      localStorage.condition5_errorcount = Number(localStorage.condition5_errorcount) + 1;            }
                                }

                                //condition 6
                                if(lowercase_string_check.includes("insert clp category")==true)
                                {
            error_msg6 = "CLP Category not removed\n";
            flag= 1;
                                                if             (localStorage.getItem("condition6_errorcount") === null) {
                                                                                localStorage.setItem("condition6_errorcount", 1);                            }
                                                else{      localStorage.condition6_errorcount = Number(localStorage.condition6_errorcount) + 1;            }
                                }

                                //condition 7
        if((item_value=="ASIN Review Request: Retail/CS Group" || item_value=="ASIN Review Request: Retail Group") && lowercase_string_check.includes("https://sellercentral")==true)
        {
            error_msg7 = "Retail Blurb not used\n";
            flag= 1;
                                                if             (localStorage.getItem("condition7_errorcount") === null) {
                                                                                localStorage.setItem("condition7_errorcount", 1);                            }
                                                else{      localStorage.condition7_errorcount = Number(localStorage.condition7_errorcount) + 1;            }
        }

                                //condition 8
        if((item_value=="ASIN Review Request: Seller Support Group" || item_value=="ASIN Review Request: FBA Group") && (lowercase_string_check.includes("https://vendorcentral")==true))
                                {
            error_msg8 = "Seller Support/ FBA Blurb not used\n";
            flag= 1;
                                                if             (localStorage.getItem("condition8_errorcount") === null) {
                                                                                localStorage.setItem("condition8_errorcount", 1);                            }
                                                else{      localStorage.condition8_errorcount = Number(localStorage.condition8_errorcount) + 1;            }
                                }

                                //condition 9
                                if(lowercase_string_check.includes("environmentally hazardous substance")==true)
                                {
            error_msg9 = "Non-DG blurb not used for Unregulated Exceptions\n";
            flag= 1;
                                                if             (localStorage.getItem("condition9_errorcount") === null) {
                                                                                localStorage.setItem("condition9_errorcount", 1);                            }
                                                else{      localStorage.condition9_errorcount = Number(localStorage.condition9_errorcount) + 1;            }
                                }

                                //condition 10
        if((lowercase_string_check.includes("lithium")==true) && (lowercase_string_check.includes("automatically transshipped")==true || lowercase_string_check.includes("please transship to a hazmat fc")==true))
        {
            error_msg10 = "Tranship line not removed\n";
            flag= 1;
                                                if             (localStorage.getItem("condition10_errorcount") === null) {
                                                                                localStorage.setItem("condition10_errorcount", 1);                         }
                                                else{      localStorage.condition10_errorcount = Number(localStorage.condition10_errorcount) + 1;         }
        }

                                //condition 11
        if((type=="Hazmat US") && (lowercase_string_check.includes("https://vendorcentral.amazon.ca")==true || lowercase_string_check.includes("https://sellercentral.amazon.ca")==true || lowercase_string_check.includes("https://vendorcentral.amazon.in")==true || lowercase_string_check.includes("https://sellercentral.amazon.in")==true || lowercase_string_check.includes("https://vendorcentral.amazon.co.uk")==true || lowercase_string_check.includes("https://sellercentral-europe.amazon.com/")==true))
        {
                                                error_msg11 = "US Blurb not used for US MP\n";
                                                flag= 1;
                                                if             (localStorage.getItem("condition11_errorcount") === null) {
                                                                                localStorage.setItem("condition11_errorcount", 1);                         }
                                                else{      localStorage.condition11_errorcount = Number(localStorage.condition11_errorcount) + 1;         }
        }

                                //condition 12
        if((type=="Hazmat UK") && (lowercase_string_check.includes("https://vendorcentral.amazon.ca")==true || lowercase_string_check.includes("https://sellercentral.amazon.ca")==true || lowercase_string_check.includes("https://vendorcentral.amazon.in")==true || lowercase_string_check.includes("https://sellercentral.amazon.in")==true || lowercase_string_check.includes("https://sellercentral.amazon.com/")==true || lowercase_string_check.includes("https://vendorcentral.amazon.com/")==true))
        {
                                                error_msg12 = "UK Blurb not used for UK MP\n";
                                                flag= 1;
                                                if             (localStorage.getItem("condition12_errorcount") === null) {
                                                                                localStorage.setItem("condition12_errorcount", 1);                         }
                                                else{      localStorage.condition12_errorcount = Number(localStorage.condition12_errorcount) + 1;         }
        }

                                //condition 13
        if((type=="Hazmat CA") && (lowercase_string_check.includes("https://sellercentral-europe.amazon.com")==true || lowercase_string_check.includes("https://vendorcentral.amazon.co.uk")==true || lowercase_string_check.includes("https://sellercentral.amazon.in")==true || lowercase_string_check.includes("https://vendorcentral.amazon.in")==true || lowercase_string_check.includes("https://sellercentral.amazon.com/")==true || lowercase_string_check.includes("https://vendorcentral.amazon.com/")==true))
        {
                                                error_msg13 = "CA Blurb not used for CA MP\n";
                                                flag= 1;
                                                if             (localStorage.getItem("condition13_errorcount") === null) {
                                                                                localStorage.setItem("condition13_errorcount", 1);                         }
                                                else{      localStorage.condition13_errorcount = Number(localStorage.condition13_errorcount) + 1;         }
        }

                                //condition 14
        if((type=="Hazmat IN") && (lowercase_string_check.includes("https://sellercentral-europe.amazon.com")==true || lowercase_string_check.includes("https://vendorcentral.amazon.co.uk")==true || lowercase_string_check.includes("https://sellercentral.amazon.com/")==true || lowercase_string_check.includes("https://vendorcentral.amazon.com/")==true || lowercase_string_check.includes("https://sellercentral.amazon.ca")==true || lowercase_string_check.includes("https://vendorcentral.amazon.ca")==true))
        {
                                                error_msg14 = "IN Blurb not used for IN MP\n";
                                                flag= 1;
                                                if             (localStorage.getItem("condition14_errorcount") === null) {
                                                                                localStorage.setItem("condition14_errorcount", 1);                         }
                                                else{      localStorage.condition14_errorcount = Number(localStorage.condition14_errorcount) + 1;         }
        }

                                //condition 15
                                if(lowercase_string_check.includes("select based on the reason")==true)
                                {
            error_msg15 = "Select based on the reason keyword in blurb\n";
            flag= 1;
                                                if             (localStorage.getItem("condition15_errorcount") === null) {
                                                                                localStorage.setItem("condition15_errorcount", 1);                         }
                                                else{      localStorage.condition15_errorcount = Number(localStorage.condition15_errorcount) + 1;         }
                                }

                                //condition 16
                                if(lowercase_string_check.includes("insert code / mid")==true)
                                {
            error_msg16 = "Vendor code not entered\n";
            flag= 1;
                                                if             (localStorage.getItem("condition16_errorcount") === null) {
                                                                                localStorage.setItem("condition16_errorcount", 1);                         }
                                                else{      localStorage.condition16_errorcount = Number(localStorage.condition16_errorcount) + 1;         }
                                }

                                //condition 17
                                if(lowercase_string_check.includes("insert link")==true)
                                {
            error_msg17 = "Paragon case link not entered\n";
            flag= 1;
                                                if             (localStorage.getItem("condition17_errorcount") === null) {
                                                                                localStorage.setItem("condition17_errorcount", 1);                         }
                                                else{      localStorage.condition17_errorcount = Number(localStorage.condition17_errorcount) + 1;         }
                                }

                                //condition 18
                                if(lowercase_string_check.includes("insert seller id")==true)
                                {
            error_msg18 = "Seller id not entered\n";
            flag= 1;
                                                if             (localStorage.getItem("condition18_errorcount") === null) {
                                                                                localStorage.setItem("condition18_errorcount", 1);                         }
                                                else{      localStorage.condition18_errorcount = Number(localStorage.condition18_errorcount) + 1;         }
                                }

                                //condition 19
                                if(lowercase_string_check.includes("choose either sds or exemption sheet depending on the product type")==true)
                                {
            error_msg19 = "Blurb not amended\n";
            flag= 1;
                                                if             (localStorage.getItem("condition19_errorcount") === null) {
                                                                                localStorage.setItem("condition19_errorcount", 1);                         }
                                                else{      localStorage.condition19_errorcount = Number(localStorage.condition19_errorcount) + 1;         }
                                }

                                //condition 20
                                if(lowercase_string_check.includes("choose as applicable")==true)
                                {
            error_msg20 = "Blurb not amended\n";
            flag= 1;
                                                if             (localStorage.getItem("condition20_errorcount") === null) {
                                                                                localStorage.setItem("condition20_errorcount", 1);                         }
                                                else{      localStorage.condition20_errorcount = Number(localStorage.condition20_errorcount) + 1;         }
                                }

                                //condition 21
                                if(lowercase_string_check.includes("incomplete and/or inaccurate and/or conflicting")==true)
                                {
            error_msg21 = "Blurb not amended\n";
            flag= 1;
                                                if             (localStorage.getItem("condition21_errorcount") === null) {
                                                                                localStorage.setItem("condition21_errorcount", 1);                         }
                                                else{      localStorage.condition21_errorcount = Number(localStorage.condition21_errorcount) + 1;         }
                                }

                                //condition 22
                                if(lowercase_string_check.includes("select based on the reason(s) below")==true)
                                {
            error_msg22 = "Blurb not amended\n";
            flag= 1;
                                                if             (localStorage.getItem("condition22_errorcount") === null) {
                                                                                localStorage.setItem("condition22_errorcount", 1);                         }
                                                else{      localStorage.condition22_errorcount = Number(localStorage.condition22_errorcount) + 1;         }
                                }

                                //condition 23
        /*if((lowercase_string_check.includes("merge")==false) && (lowercase_title.includes("source")==true || lowercase_title.includes("target")==true || lowercase_title.includes("darwin")==true || lowercase_title.includes("deprecation")==true || lowercase_title.includes("merge")==true || lowercase_title.includes("deprecate")==true || lowercase_description.includes("source")==true || lowercase_description.includes("target")==true || lowercase_description.includes("darwin")==true || lowercase_description.includes("deprecation")==true || lowercase_description.includes("merge")==true || lowercase_description.includes("deprecate")==true))
        {
            error_msg23 = "Merge issue blurb not used\n";
            flag= 1;
                                                if             (localStorage.getItem("condition23_errorcount") === null) {
                                                                                localStorage.setItem("condition23_errorcount", 1);                         }
                                                else{      localStorage.condition23_errorcount = Number(localStorage.condition23_errorcount) + 1;         }
        }*/

        if(flag==1)
        {
                                                swal({
                                                                title: "Alarm",
                                                                text: "Following errors has been observed :\n\n" + error_msg1 + error_msg2 + error_msg3 + error_msg4 + error_msg5 + error_msg6 + error_msg7 + error_msg8 + error_msg9 + error_msg10 + error_msg11 + error_msg12 + error_msg13 + error_msg14 + error_msg15 + error_msg16 + error_msg17 + error_msg18 + error_msg19 + error_msg20 + error_msg21 + error_msg22 + error_msg23,
                                                                button: "OK"
            });
        }
        else if(flag==0)
        {
            $("#save-button").click();
            //alert("Safest");
        }
    });
}

window.onLoad = testAlert();