SLDir

read data

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        SLDir
// @namespace   Srilanka
// @include     http://eservices.elections.gov.lk/myVoterRegistrationDraft.aspx
// @version     1.0.3
// @require 	http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant       GM_xmlhttpRequest

// @description read data
// ==/UserScript==

$(document).ready(function(){
 var NIC;
  
  //alert("fire");

//check result table
if(document.getElementById("ContentPlaceHolder1_DetailsView").children[0].children.length>1){

//some result,extract,post to myDB
  
  var person=[];
  var rows=document.getElementById("ContentPlaceHolder1_DetailsView").children[0].children;
  for(i=0;i<9;i++){
    
    person[i]=rows[i].children[1].innerHTML;
    
   
  }
  
  
 var postData={
   'name':person[0],
   'NIC': person[1].split("/").pop().trim(),
   'SLNIC':person[1].split("/")[0].trim(),
   'disNum':person[2].split("-")[0].trim(),
   'disName':person[2].split("-").pop().trim(),
   'gender':person[4],
   'pollingDiv':person[6],
   'pdNumber':person[7],
   'serialNo':0,
 }
  
  /*url="http://slelection.esy.es";
 $.post(url+'/election.php',postData,function(data){
	
	alert("Sent");
});*/
 
 
GM_xmlhttpRequest ( {
method: "POST",
url: "http://ca371a58.ngrok.io/election.php",
data: JSON.stringify(postData)

,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function (response) { 
//console.log ( response.responseText);


//alert(response.responseText);


//alert("im here");
  
//current id is correct,divide/10 ,*10
  
  

  NIC=Number($("#ContentPlaceHolder1_txtNIC").val().split("V")[0]);
  var x=NIC/10;
  var rem=NIC%10;

  if(rem!=0){
    NIC=Math.ceil(x);
    
  }
  else{
    NIC=x+1;
  }
  
  NIC=NIC*10
  //alert(NIC);
  
//alert("done");
$("#ContentPlaceHolder1_txtNIC").val(NIC+"V");


//set code

var code="";
for(i=1;i<6;i++){
var charid= "ContentPlaceHolder1_imbC"+i;
code=code+document.getElementById(charid).src.split("/").pop().split(".")[0];

}


$("#ContentPlaceHolder1_txtCode").val(code);

$("#ContentPlaceHolder1_cmdDisplay").click();




}

} );
  
  

}else{

//no result
//current id is wrong,++1
  NIC=Number($("#ContentPlaceHolder1_txtNIC").val().split("V")[0]);
  NIC++;
//alert("not found");


$("#ContentPlaceHolder1_txtNIC").val(NIC+"V");


//set code

var code="";
for(i=1;i<6;i++){
var charid= "ContentPlaceHolder1_imbC"+i;
code=code+document.getElementById(charid).src.split("/").pop().split(".")[0];

}


$("#ContentPlaceHolder1_txtCode").val(code);

$("#ContentPlaceHolder1_cmdDisplay").click();



}


//nextCall

//set proper NIC

//just demo
//var NIC=Number($("#ContentPlaceHolder1_txtNIC").val().split("V")[0]);
//alert(NIC);
//NIC++;



});