Verint Profile Scrape Snippet

by dixalex

JavaScript

// Comment out the "masterArray" variable after the first invocation.
var masterArray = new Array();

// Variable to store our intervalID
let intervalId;

// On final page of Verint pagination, copy contents of the browser console
// Paste copied contents and format in text editor of choice.
// Tweak pasted contents and then paste into Excel, splitting the data with the "~" character as the delimiter
startProfileSearch();

function startProfileSearch() {
  // check if an interval has already been set up
  if (!intervalId) {
    intervalId = setInterval(
      createProfileArray("Alexander Dixon", new Date("12-31-2022")),
      1250,
    );
  }
}

function createProfileArray(userName, yearThreshold) {
  $(".content tr[id*=_cphBody_grdItems_ct]:has(a[href])").each(
    function (index, element) {
      var surveyTitle = $.trim($(element).find("td:has(a[href])").text());
      var lastModified = $.trim($(element).find('td[title*="day"]').text());
      var dateTest = new Date(
        $.trim($(element).find('td[title*="day"]').attr("title")),
      );
      var projectID = $(element)
        .find("td:has(a[href])")
        .find("a[href]")
        .attr("href")
        .match(/pid=(\d+)/);

      var profileOwner = $.trim(
        $(element)
          .find("td:contains(" + userName + ")")
          .text(),
      )

      if (profileOwner.length > 0 && dateTest <= yearThreshold) {
        masterArray.push(
          surveyTitle +
            "~" +
            lastModified +
            "~" +
            profileOwner +
            "~" +
            "" +
            projectID[1].toString() +
            "",
        );
      }
    },
  )

  if ($(".aspNetDisabled.pagNext").length === 0) {
    __doPostBack("ctl00$cphBody$grdItems$ctl00$ctl03$ctl01$btnNext", "");
  } else {
    endProfileSearch(masterArray);
  }
}

function endProfileSearch(foundProfileArray) {
  console.log(foundProfileArray);
  clearInterval(intervalId);
  // release our intervalId from the variable
...