Raw Source
kalpdev.1 / Auto AirItk Sideline v3

// ==UserScript==
// @name     Auto AirItk Sideline v3
// @run-at   document-body
// @version      0.8
// @match    https://argus.aka.amazon.com/*
// @include  https://argus.aka.amazon.com/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @updateURL https://openuserjs.org/meta/kalpdev.1/Auto_AirItk_Sideline_v3.meta.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
// @downloadURL https://openuserjs.org/install/kalpdev.1/Auto_AirItk_Sideline_v3.user.js
// @license MIT
//@require https://cdn.jsdelivr.net/npm/sweetalert2@10
// @grant    GM_addStyle
// @match    http://pnq-412gv7q.ant.amazon.com:8087/*
// @grant    GM_xmlhttpRequest
// @grant    GM_registerMenuCommand
// @grant    GM_setValue
// @grant    GM_getValue
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/


function addCustomSearchResult (jNode) {
    //$(".submit-product-card-classification").hide ();
 var toastMixin = Swal.mixin({
    toast: true,
    icon: 'success',
    title: 'General Title',
    animation: false,
    position: 'top-left',
    showConfirmButton: false,
    customClass: 'lookup-custom-height',
    timer: 2000,
    timerProgressBar: true,
    didOpen: (toast) => {
      toast.addEventListener('mouseenter', Swal.stopTimer)
      toast.addEventListener('mouseleave', Swal.resumeTimer)
    }
  });
    $('.submit-product-card-classification').click(function(){


	setTimeout(function(){ add_description();   }, 100);

	function add_description(){
           var usernameElement = document.querySelector('.spoof-user-badge-pic');
      var username = usernameElement ? usernameElement.alt : null;

      var asinElement = document.querySelector('span.ng-binding');
    var asin = asinElement ? asinElement.innerText.trim() : '';

         GM_xmlhttpRequest({
            method: "POST",
            url: "http://pnq-412gv7q.ant.amazon.com:8087/sdj/save_entry",
                                                data: "username="+username+"&asin="+asin,
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            onload: function(response) {

 const sidelineButton = document.querySelector('#dtSearch > div.sideline-asin-container > sideline-work-item > button') // get the sideline button

  toastMixin.fire(response.responseText);

  if (response.responseText === "Already In Excluded Bucket") {
    sidelineButton.click();
        const finalconfirm = setInterval(function () {
                    const slButton = document.querySelector("body > div.sweet-alert.showSweetAlert.visible > div.sa-button-container > div > button")
                   if (slButton) {
                       slButton.click();
                      clearInterval(finalconfirm);
                      // document.location.reload(true);
                 }
                }, 200);

  } else if (response.responseText === "asinmatrix") {

    console.log("met2");

  } else {

    console.log("fresh asin");
    // fresh asin
  }






            }
        });



	}
//alert("Hey");
//console.log("Heyyyyyyy");



    });
}



var url= window.location.href;
var isArgusDG = /^https:\/\/argus.aka.amazon.com\/#!\/dg(.*)/i.test(url);

if (isArgusDG){
    console.log("This is an Argus DG Page!");
              waitForKeyElements (".submit-product-card-classification", addCustomSearchResult);
}else{
    console.log("This is not an Argus DG Page!");
}