Ogame manzanasfrescas 1

By mohace Last update Sep 18, 2007 — Installed 853 times. Daily Installs: 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 3, 0, 1, 4, 0, 1, 0, 2, 0, 3, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1
// ==UserScript==
// @name           Ogame manzanasfrescas 1
// @author         mohace
// @date           18-09-2007
// @version        0.3
// @namespace     
// @description    Crea links desde estadísticas ogame a manzanasfrescas en los nombres de cada jugador.
// @include        http://*.ogame.*/game/index.php?page=stat*
// ==/UserScript==

// Editar esta instruccion poniendo su propio nick tal cual aparece en Ogame (entre las comillas)
var usuario = 'macoco'
// Editar esta instruccion poniendo el universo en el cual jugamos. Si dejamos el valor en 0 el script intentar� determinar el univeros en forma automatica.
var uni = 20
// Editar esta instruccion poniendo la preferencia de las estadisticas a ver en forma predeterminada, 7, 30 o 90 dias (entre las comillas)
var dias = '90'
// Editar esta instruccion poniendo la identificacion de usuario (obtener de manzanasfrescas).
var userIDpropia = 123456

// Para obtener jugador y el userIDotros
var b_Snapshot = document.evaluate('//th[2]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
var c_Snapshot = document.evaluate('//th[3]/a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );

var contador1 = 0
var contador2 = -2

// Para contar el numero de jugadores
for ( var j=0 ; j < b_Snapshot.snapshotLength; j++ ) {

	contador2 = contador2 + 1
	
}
	
// Rutina principal
for ( var i=0 ; i < b_Snapshot.snapshotLength; i++ ) {
	
	if (usuario == b_Snapshot.snapshotItem(i).textContent) {

		contador1 = 1
		var pos = c_Snapshot.snapshotItem(i).href.indexOf('&messageziel=');
		var userIDotros = c_Snapshot.snapshotItem(i).href.substr(pos+13);
		var nuevoEnlace = document.createElement("a");
		//nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?id=' + userIDpropia + '&uni=' + uni
		nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?startrange=0&g=' + dias + 'd&uni=' +  uni + '&id=' + userIDpropia
		var nodoTexto = document.createTextNode(b_Snapshot.snapshotItem(i).textContent);
		nuevoEnlace.appendChild(nodoTexto);
		nuevoEnlace.style.color = '#00FF00';
		b_Snapshot.snapshotItem(i).textContent = ''
		b_Snapshot.snapshotItem(i).appendChild(nuevoEnlace)
		
	}	
		
	if (contador1 == 0) {

		var pos = c_Snapshot.snapshotItem(i).href.indexOf("&messageziel=");
		var userIDotros = c_Snapshot.snapshotItem(i).href.substr(pos+13);
		var nuevoEnlace = document.createElement("a");
		//nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?id=' + userIDotros + '&uni=' + uni
		nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?startrange=0&g=' + dias + 'd&uni=' +  uni + '&id=' + userIDotros
		var nodoTexto = document.createTextNode(b_Snapshot.snapshotItem(i).textContent);
		nuevoEnlace.appendChild(nodoTexto);
		b_Snapshot.snapshotItem(i).textContent = ''
		b_Snapshot.snapshotItem(i).appendChild(nuevoEnlace)

	} else {

		if (usuario == b_Snapshot.snapshotItem(i).textContent) {
		
			var pos = c_Snapshot.snapshotItem(contador2).href.indexOf("&messageziel=");
			var userIDotros = c_Snapshot.snapshotItem(contador2).href.substr(pos+13);
			var nuevoEnlace = document.createElement("a");
			//nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?id=' + userIDotros + '&uni=' + uni
			nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?startrange=0&g=' + dias + 'd&uni=' +  uni + '&id=' + userIDotros
			var nodoTexto = document.createTextNode(b_Snapshot.snapshotItem(contador2+1).textContent);
			nuevoEnlace.appendChild(nodoTexto);
			b_Snapshot.snapshotItem(contador2+1).textContent = ''
			b_Snapshot.snapshotItem(contador2+1).appendChild(nuevoEnlace)
		
		} else {
		
			var pos = c_Snapshot.snapshotItem(i).href.indexOf("&messageziel=");
			var userIDotros = c_Snapshot.snapshotItem(i-1).href.substr(pos+13);
			var nuevoEnlace = document.createElement("a");
			//nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?id=' + userIDotros + '&uni=' + uni
			nuevoEnlace.href = 'http://www.manzanasfrescas.com/userdetails.php?startrange=0&g=' + dias + 'd&uni=' +  uni + '&id=' + userIDotros
			var nodoTexto = document.createTextNode(b_Snapshot.snapshotItem(i).textContent);
			nuevoEnlace.appendChild(nodoTexto);
			b_Snapshot.snapshotItem(i).textContent = ''
			b_Snapshot.snapshotItem(i).appendChild(nuevoEnlace)

		}	
	}
}

function extraer(texto, etqini, etqfin)
{
var ind0, ind1, parte ="";
ind0 = texto.indexOf(etqini);
if (ind0 >=0)
{
ind1 = texto.indexOf(etqfin);
if (ind1>ind0)
parte = texto.substring(ind0+etqini.length, ind1);
}
return parte;
}