ipl2016

extract playingXI

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        ipl2016
// @namespace   csa
// @include     http://www.espncricinfo.com/indian-premier-league-2015/engine/match/*
// @require 	http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version     1.15
// @description extract playingXI
// ==/UserScript==


$(document).ready(function(){


//1st innings
var batting1=document.getElementsByClassName("batting-table innings")[0];

var len=batting1.children[0].children.length;
var battedInfo=batting1.children[0].children;
var team1= [];
var j=0;
//loop 1st inning
for(i=0;i<len;i++){
	

	if(battedInfo[i].hasAttributes()==false){
		team1[j]=battedInfo[i].children[1].children[0].innerHTML;
		j++;
	}
	
}

var batting2=document.getElementsByClassName("batting-table innings")[1];

var len=batting2.children[0].children.length;
var battedInfo=batting2.children[0].children;
var team2= [];
var k=0;
//loop 1st inning
for(i=0;i<len;i++){
	

	if(battedInfo[i].hasAttributes()==false){
		team2[k]=battedInfo[i].children[1].children[0].innerHTML;
		k++;
	}
	
}



//1st inning tobat
if(document.getElementsByClassName("more-match-stats")[0].children.length>1){
//there are some players did not batted
var dnb= document.getElementsByClassName("more-match-stats")[0].children[0].children[0];
var len= dnb.children.length;

for(i=1;i<len;i++){
	
	team1[j]=dnb.children[i].children[0].innerHTML;
	j++;
}	
}


//2nd inning tobat

if(document.getElementsByClassName("more-match-stats")[1].children.length>1){
//there are some players did not batted
var dnb= document.getElementsByClassName("more-match-stats")[1].children[0].children[0];
var len= dnb.children.length;

for(i=1;i<len;i++){
	
	team2[k]=dnb.children[i].children[0].innerHTML;
	k++;
}	
}



//var object ={'matchid':Number(document.location.href.split("/").pop().split(".")[0]),'team1':t1,'team2':t2};

var id= document.location.href.split("/").pop().split(".")[0];
var url= "http://sureleave.esy.es";

var postData= {'id':id,'team1':team1,'team2':team2};
$.post(url+'/save.php',postData,function(data){
	
	alert("Sent");
});









})