// ==UserScript==
// @name filtrowikiaves
// @namespace -
// @description Adiciona filtro que permite comparar duas fontes (passarinheiro/local)
// @include http://www.wikiaves.com/especies.php?*
// @include http://www.wikiaves.com.br/especies.php?*
// @version 1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.3/jquery-ui.min.js
// @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @grant GM_addStyle
// @downloadURL none
// ==/UserScript==
if(!('contains' in String.prototype)){String.prototype.contains = function(str, startIndex){return -1 !== String.prototype.indexOf.call(this, str, startIndex);};}
//TODO: mudar pagina "include" antes da analize para &o=3
function comeca() {
$(".textpadding > div").append($(" | Filtrar lifers de: "));
$(".textpadding > div").append($(""));
$(".textpadding > div").append($(""));
$(".textpadding > div").append($(''));
$(".textpadding > div").append($(''));
document.getElementById("botus").onclick = function (){
document.getElementById("botus").style.display = "none";
document.getElementById("botcid").style.display = "none";
document.getElementById("usuario").style.display = "";
//por title das coisa aque e deixar vazio la em cima
}
document.getElementById("botcid").onclick = function (){
document.getElementById("botus").style.display = "none";
document.getElementById("botcid").style.display = "none";
document.getElementById("cidade").style.display = "";
$(".buscacidade").autocomplete({
minLength: 2,
source: "getCidadesJSON.php",
open: zebrar,
select: function(event, ui) { document.location = "cidade.php?c="+ui.item.id; }
}).data( "ui-autocomplete" )._renderItem = renderBuscaCidade;
//location.assign("javascript:$('.buscacidade').blur(function(e) {if(e.target.value == '') {$('#'+e.target.name+'_hidden'').val('');}})");
//javascript:$('.buscacidade').autocomplete({minLength: 2,source: 'getCidadesJSON.php',open: zebrar,select: function(event, ui) { document.location = 'cidade.php?c='+ui.item.id; }}).data('ui-autocomplete')._renderItem = renderBuscaCidade
//$('.buscacidade').jLabel();});");
};
// $("head").append($('\
// '));
// $("head").append($('\
// '));
//ui.item."login" -> pode ser id , label (nome/cidade) , uf
}
function analisa() {
var tabela = document.getElementsByClassName('especies') [0];
var seletorc, cago;
for (var i = 2; i<=tabela.rows.length; i++) {
var row = tabela.rows[i];
seletorc = 'tr.especie:nth-child(' + i + ') > td:nth-child(5) > a:nth-child(1)';
cago = $(seletorc).attr('href');
if (cago===undefined){
cago = $('tr.especie:nth-child(' + i + ') > td:nth-child(4) > a:nth-child(1)').attr('href');}
var res= cago.substring((cago.indexOf("s=")+2));
if (extrato.contains(res)){
var cuia = 'tr.especie:nth-child(' + i + ')';
$(cuia).hide();
}
}
}
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);
}
waitForKeyElements('.ttPage', comeca);