FellowshipOne Add View Duplicates Link

Checks to see if duplicates exist for individual and adds link to duplicates page on profile page if a potential duplicate is found. Link text changes based on likeliness of duplicate.

اعتبارا من 17-04-2017. شاهد أحدث إصدار.

// ==UserScript==
// @name         FellowshipOne Add View Duplicates Link
// @namespace    [email protected]
// @version      0.1
// @description  Checks to see if duplicates exist for individual and adds link to duplicates page on profile page if a potential duplicate is found. Link text changes based on likeliness of duplicate.
// @author       Tony Visconti
// @match        https://portal.fellowshipone.com/people/Individual/Index.aspx?id=*
// @match        https://portal.staging.fellowshipone.com/people/Individual/Index.aspx?id=*
// @grant        none
// ==/UserScript==

//function is compliments of http://www.jquerybyexample.net/2012/06/get-url-parameters-using-jquery.html
var getUrlParameter = function getUrlParameter(sParam) {
  var sPageURL = decodeURIComponent(window.location.search.substring(1)),
    sURLVariables = sPageURL.split('&'),
    sParameterName,
    i;

  for (i = 0; i < sURLVariables.length; i++) {
    sParameterName = sURLVariables[i].split('=');

    if (sParameterName[0] === sParam) {
      return sParameterName[1] === undefined ? true : sParameterName[1];
    }
  }
};

//basic javascript ajax was used here instead of jquery because I couldn't get it to work with F1's version of jquery. When I loaded my own I also ran into issues.
function SetDuplicateInfo() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {

      // check for this image with 5 dots and 4 dots https://screencast.com/t/SEd1zFMjP7 which only shows up when there is a potential match
      var highRank = this.responseText.search(/highRank.gif/i);
      //window.alert(highRank);
      var mediumhighRank = this.responseText.search(/images\/mediumHighRank/i);

      var noDuplicates = this.responseText.search(/No potential duplicates found/i);
      //window.alert(mediumhighRank);
      //window.alert(noDuplicates);

      if (highRank > 0 || mediumhighRank > 0) {
        document.getElementById("viewDuplicates").innerHTML = '<a id="viewDuplicates" href="/people/householdGeneral/DuplicateFinderResults.aspx?ind_id=' + id + '" class="icon_view">Likely Duplicates Found</a>';
      } else if (noDuplicates > 0) {
        document.getElementById("viewDuplicates").innerHTML = 'No Potential Duplicates Found';
      } else {
        document.getElementById("viewDuplicates").innerHTML = '<a id="viewDuplicates" href="/people/householdGeneral/DuplicateFinderResults.aspx?ind_id=' + id + '" class="icon_view">Potential Duplicates Found</a>';
      }
    }
  };
  xhttp.open("GET", "/people/householdGeneral/DuplicateFinderResults.aspx?ind_id=" + id, true);
  xhttp.send();
}

var id = getUrlParameter('id');
var appendhtml = '<li id=viewDuplicates></li>';
var node = document.evaluate('//*[@id="main_content"]/div[2]/div/ul', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
node.innerHTML += appendhtml;
SetDuplicateInfo();