Phone Lookup

Phone Lookup

Make sure you replace “172.17.0.0” with your phone IP in two places: the ‘@include’ line and the ‘var phoneIp =’ line;

// ==UserScript==
// @name Phone Lookup 0.2
// @namespace https://code.thegreatdivide.info/
// @version 0.2
// @description Lookup accounts based on who is calling
// @grant none
// @author SeanWa
// @include https://secure1.inmotionhosting.com/*
// @include http://172.17.0.0/calllog.htm?phonelookup
// ==/UserScript==

var phoneIp = '172.17.0.0';

function doInjection(){
  jQuery(function($) {
    var lastLog = $('#Answered td')[1].innerHTML;
    //alert(lastLog);
    var split = lastLog.split(',');
    var phoneNumber = split[1].trim();
    if(phoneNumber.substr(0,5) == '00000'){
      window.location = 'https://secure1.inmotionhosting.com/admin/';
    }else{
      var form = document.createElement('FORM');
      form.action = 'https://secure1.inmotionhosting.com/admin/account';
      form.method = 'POST';

      form.innerHTML = '<input name="search" value="' + phoneNumber + '"></input>' +
        '<select name="search_type"><option value="telephone" selected="selected"></option></select>';

      $('body').append(form);
      form.submit();
    }
  });
}

function doPPInjection(){
  jQuery(function($) {
    var but = document.createElement('button');
    but.innerHTML = 'Phone Search';
    but.style= "margin-top: .6em";
    $(but).click(function(){
      window.location = 'http://' + phoneIp + '/calllog.htm?phonelookup';
    });
    $('.container-fluid').first().append(but);
  });
}

var hostname = window.location.hostname;
if(hostname.indexOf(phoneIp)!= -1){
  var head = document.getElementsByTagName('head')[0];
  var jq = document.createElement('SCRIPT');
  jq.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js');
  jq.addEventListener('load', function () {
    doInjection();
  });
  head.appendChild(jq);
}else if(hostname.indexOf('secure1.inmotionhosting.com')!= -1){
  doPPInjection();
}