Extract Surnames

Extract Surnames from website

As of 2018-04-10. See the latest version.

// ==UserScript==
// @name        Extract Surnames
// @name:en        Extract Surnames ds
// @description Extract Surnames from website
// @description:en Extract Surnames from websitedd sd
// @include     http://indiachildnames.com/surname/*
// @author      atul
// @version     1.0.2
// @grant       none
// @namespace   https://greasyfork.org/en/users/100769-atul-k
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// ==/UserScript==
(function () {
  var lNames = "";
  var Names = $("#contentstable :first").children();
  var storedValue = localStorage.getItem('clodura');
  if (!storedValue) {
      storedValue = '';
      localStorage.setItem('clodura', storedValue);
  }
  
  for(var i=0; i < Names.length; i++) {
  	var surname = $(Names[i]).children('td :first').text();
    var language = $(Names[i]).children('td :nth-child(2)').text();
    var origin = $(Names[i]).children('td :last').text();
    var final = surname + "#" + language + "#" + origin;
    lNames = lNames + final + '\n';
  }
  
  storedValue = storedValue + lNames;  
  localStorage.setItem('clodura', storedValue);
  
  var a = $('table#clienttable > tbody > tr > td:nth-child(2) > table > tbody > tr:nth-child(5) > td > table > tbody >tr > td:last').children('font:last ~ a')[0];
  
  if(a) {
      var href = a.href;
      href = href.split('http://indiachildnames.com/surname/')[1]
      window.location.replace(href);
  } 
  else {
      var c = $('table#clienttable > tbody > tr > td:nth-child(2) > table > tbody > tr:nth-child(5) > td > table > tbody >tr > td:last').children('font:first ~ a:first')[0];
    
      if(c) {
          var href = c.href
          href = href.split('http://indiachildnames.com/surname/')[1]
          window.location.replace(href);
      }
  }
}) ();