Greasy Fork is available in English.
Adiciona filtro que permite comparar duas fontes (passarinheiro/local)
当前为
// ==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 http://greasyfork.icu/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @grant GM_addStyle
// ==/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($("<span> | <b><a href=#>Filtrar lifers de: </a></b></span> "));
$(".textpadding > div").append($("<button type='button' id='botus'> Usuário </button>"));
$(".textpadding > div").append($("<button type='button' id='botcid'> Cidade </button>"));
$(".textpadding > div").append($('<input style="width:200px;display:none" id="usuario" title="(Selecione um Usuário)" tabindex="3" size="36" class="buscausuario ui-autocomplete-input" name="usuario" autocomplete="off">'));
$(".textpadding > div").append($('<input style="width:200px;display:none" id="cidade" title="(Selecione uma Cidade)" tabindex="3" size="36" class="buscacidade ui-autocomplete-input" name="cidade" autocomplete="off">'));
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($('\
// <script type="text/javascript"> \
// $(function() {\
// $(".buscacidade").blur(function(e) {\
// if(e.target.value == "") {\
// $("#"+e.target.name+"_hidden").val("");\
// } \
// });\
// $(".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();\
// });\
// </script>'));
// $("head").append($('\
// <script type="text/javascript">\
// $(function() {\
// $(".buscausuario").blur(function(e) {\
// if(e.target.value == "") {\
// $("#"+e.target.name+"_hidden").val("");\
// }});\
// $(".buscausuario").autocomplete({\
// minLength: 2,\
// source: "getUsuariosJSON.php",\
// open: zebrar,\
// select: function(event, ui) {\
// $("#"+event.target.name+"_hidden").val(ui.item.id);\
// document.location.href="/perfil_"+ui.item.label;\
// }\
// }).data( "ui-autocomplete" )._renderItem = renderBuscaCidade;\
// $(".buscausuario").jLabel();\
// });\
// </script>'));
//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);