Greasy Fork

Greasy Fork is available in English.

anobagual

Conta quantas espécies de aves da lista do usuário tiveram seu registro em determinado local

当前为 2018-01-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        anobagual
// @namespace   yadaa
// @description Conta quantas espécies de aves da lista do usuário tiveram seu registro em determinado local
// @include     http://www.wikiaves.com/especies.php?*&o=3&ef=
// @include     http://www.wikiaves.com.br/especies.php?*&o=3&ef=
// @version     1.3
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @require     http://greasyfork.icu/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @grant       GM_addStyle
// ==/UserScript==

var extrato,seletor,seletorb,seletorc,quiqui,queque,tt,pen,tem,extcid,cc,dd,temest;
var barrawidth=0;
var pe = "&p=";
var emno = " com registros fotográficos em ";

if(!('contains' in String.prototype)){String.prototype.contains = function(str, startIndex){return -1 !== String.prototype.indexOf.call(this, str, startIndex);};}

function comeca() {
  var lugar = '.ttPage';
  $(lugar).append($('\
	<form action = >\
	<fieldset>\
	<span>... no Baita Ano RS de:</span>\
	<select id = "selLocal">\
	<option>2018</option>\
	<option>2017</option>\
	<option>2016</option>\
	<option>2015</option>\
	<option>2014</option>\
	<option>2013</option>\
	<option>2012</option>\
	<option>2011</option>\
	<option>2010</option>\
	<option>2009</option>\
	<option>2008</option>\
 </select>\
  <input type = "button"\
    value = "filtrar"\
    id = "botaum"\
  </fieldset>\
 </form>\
'));
  $("#botaum").click (analisa);
}

function analisa() {
	//TODO: mudar pagina antes da analize para &o=3
	var lugarbarra = '.ttPage > form:nth-child(1) > fieldset:nth-child(1)';
	$(lugarbarra).append($('\
		<style>\
	#myProgress {\
  position: relative;\
  width: 100%;\
  height: 30px;\
  background-color: #ddd;\
	}\
	#myBar {\
  position: absolute;\
  width: 0%;\
  height: 100%;\
  background-color: #4CAF50;\
	}\
	#label {\
  text-align: center;\
  line-height: 30px;\
  color: white;\
	}\
	</style>\
		<div id="myProgress">\
  <div id="myBar">\
    <div id="label">0%</div>\
  </div>\
	</div>\
	'));		
		
		
  var tabela = document.getElementsByClassName('especies') [0];
  var local = document.getElementById("selLocal");
  var localb = "/"+local.options[local.selectedIndex].text;
	var localc = "/RS";
	document.getElementById("selLocal").disabled = true;
	document.getElementById("botaum").disabled = true;
	$(".textpadding > div:nth-child(6) > b:nth-child(1) > a:nth-child(1)").text("");
	$(".textpadding > div:nth-child(6) > b:nth-child(2) > a:nth-child(1)").text("");
	$(".textpadding > div:nth-child(6) > b:nth-child(3) > a:nth-child(1)").text("");
	$(".titulo > td:nth-child(1) > a:nth-child(1)").removeAttr("href");
	$(".titulo > td:nth-child(2) > a:nth-child(1)").removeAttr("href");
	$(".titulo > td:nth-child(3) > a:nth-child(1)").removeAttr("href");
	$(".titulo > td:nth-child(4) > a:nth-child(1)").removeAttr("href");
	$(".titulo > td:nth-child(5) > a:nth-child(1)").removeAttr("href");
	
	
	//emno=" ";
  extcid = conecta("especies.php?&t=e&e=20");
	
  for (var i = 2, row; i<=tabela.rows.length; i++) {
    row = tabela.rows[i];
		pen = Math.ceil(parseFloat($("tr.especie:nth-child("+i+") > td:nth-child(5) > a:nth-child(1)").text())/10);
		seletorc =  'tr.especie:nth-child(' + i + ') > td:nth-child(3) > a:nth-child(1)';
		quuquu = $(seletorc).text();
		
		if (!extcid.contains(quuquu)){
			var cuia = 'tr.especie:nth-child(' + i + ')';
			$(cuia).hide();
		}
		
		else{
		
    seletor = 'tr.especie:nth-child(' + i + ') > td:nth-child(5) > a:nth-child(1)';
    seletorb = 'tr.especie:nth-child(' + i + ') > td:nth-child(4) > a:nth-child(1)';
    quiqui = $(seletor).attr('href'); //registros foto
    queque = $(seletorb).attr('href'); //registros sons
		
    
	if (quiqui === undefined) { //SOH SOM
    	
        var cuia = 'tr.especie:nth-child(' + i + ')';
        $(cuia).hide();
    }
			
			
    else { // imagem E som ou soh imagem
	
	
				for (var k=1;k<=pen;k++){
					cc=(conecta(quiqui+pe+k));
					cc=cc.replace("./2018","YADA");
					cc=cc.replace("2018/2018","YADA");
                                        cc=cc.replace("href=\"/2018","YADA");
				 	if (localb==="fora do Estado"){
					 for (var g=0;g<estados.length;g++){
				 			if (cc.contains(estados[g])){temest=true;dd=null;
						 break;
								 }
						}
     			} 
     			else{dd = converte(localb);} 
						if (cc.contains(dd) == true&&cc.contains(localc)) {tem=true;break;
						}}
		 				if (tem==true) {tem=false;temest=false;}
		 				else{
          		var cuia = 'tr.especie:nth-child(' + i + ')';
          		$(cuia).hide();
							}
				 
    }
		}
		
		////AQYU
		var elem = document.getElementById("myBar");
		barrawidth+= (100/(tabela.rows.length));
		elem.style.width = barrawidth + '%';
		document.getElementById("label").innerHTML = (barrawidth.toFixed(2)) * 1  + '%';  
	}
  
  
	$(".total > b:nth-child(2)").text(contar(tabela));
	$(".total").append(emno + localb.substring(1)+" no RS.");
	$(".total").get(0).scrollIntoView();
	elem.style.width = "100%";
	document.getElementById("label").innerHTML = "100%";
	console.log(converte(localb));
	postarGoogle();
}
	
function contar(atabela) {
	tt = 0;
	for (var i = 1, row; i<=atabela.rows.length; i++) {
		row = atabela.rows[i];
		var cuia = 'tr.especie:nth-child(' + i + ')';
		if ($(cuia).is(':visible')){
			tt++; //$(cuia).css("background-color","red");
			}
			}
	return (tt);
			}
				
function conecta(x){
	var xhr;
	xhr = new XMLHttpRequest();
	xhr.open('GET', x, false);
	xhr.send();
	extrato = xhr.response;
	return (extrato);
	  
}

function converte(cidade){ //cidade
    valorcidade = cidade;
	return valorcidade;
}

function postarGoogle(){
  var usuarionome = $(".textpadding > a:nth-child(4)").text();
	var lifers = $(".total > b:nth-child(2)").text();
	var data = new Date(Date.now()).toLocaleString();
  $.ajax({					 
                url: "https://docs.google.com/forms/d/e/1FAIpQLSc_pL1htbmjGjQxP95zhMzsavJOdJBIwWwvX82DA5Vv3Lt88w/formResponse",
                data: { "entry.101800956" : usuarionome, "entry.1450640523" : lifers, "entry.412480081" : data },
                type: "POST",
                dataType: "xml",
                statusCode: {
                    0: function (){ 
                      usuarionome;
                      lifers;
                      data;
                    },
                    200: function (){
                                         usuarionome;
                      lifers;
                      data;
                                  }
                }
  });
}


waitForKeyElements('.ttPage', comeca);