Greasy Fork

Greasy Fork is available in English.

filtrowikiaves

Adiciona filtro que permite comparar duas fontes (usuário/local)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        filtrowikiaves
// @namespace   -
// @description Adiciona filtro que permite comparar duas fontes (usuário/local)
// @include     http://www.wikiaves.com/especies.php?*&o=3&ef=
// @include     http://www.wikiaves.com.br/especies.php?*&o=3&ef=
// @version     1.1
// @require    	https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @require     http://greasyfork.icu/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @grant       GM_addStyle
// ==/UserScript==

var selecidade,seleuser,mudacidade,mudauser,extrato;

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

function comeca() {	
		
	$(".textpadding > div").append($("<span> | <b><a href=#>Filtrar espécies 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 = "";
		location.href = 'javascript:void($(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);\
						seleuser = "especies.php?t=u&u="+ui.item.id;\
						mudauser = ui.item.label;\
						function conecta(){var xhr;	xhr = new XMLHttpRequest();xhr.open("GET", seleuser, false);	xhr.send();	extrato = xhr.response;	return (extrato);};conecta();\
						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();}}}\
							analisa();\
						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++;}}	return (tt);}var tabela = document.getElementsByClassName("especies") [0];contar(tabela);\
						$(".total > b:nth-child(2)").text(tt);\
						$(".total").append(" filtradas de "+mudauser);\
						$(".total").get(0).scrollIntoView();\
						document.getElementById("usuario").disabled = true;}\
			}).data( "ui-autocomplete" )._renderItem = renderBuscaCidade;\
			$(".buscausuario").jLabel();}))';

	}
	document.getElementById("botcid").onclick = function (){

		document.getElementById("botus").style.display = "none";
		document.getElementById("botcid").style.display = "none";
		document.getElementById("cidade").style.display = "";
		location.href = 'javascript:void($( 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) {\
						selecidade = "especies.php?t=c&c="+ui.item.id;\
						mudacidade = ui.item.label+"/"+ui.item.uf;\
						function conecta(){var xhr;	xhr = new XMLHttpRequest();xhr.open("GET", selecidade, false);	xhr.send();	extrato = xhr.response;	return (extrato);};conecta();\
						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();}}}\
						analisa();\
						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++;}}	return (tt);}var tabela = document.getElementsByClassName("especies") [0];contar(tabela);\
						$(".total > b:nth-child(2)").text(tt);\
						$(".total").append(" filtradas de "+mudacidade);\
						$(".total").get(0).scrollIntoView();\
						document.getElementById("cidade").disabled = true;}\
					}).data( "ui-autocomplete" )._renderItem = renderBuscaCidade;\
				$(".buscacidade").jLabel();}))';
		};
	
		//ui.item."login" -> pode ser id , label (nome/cidade) , uf	
 }

waitForKeyElements('.ttPage', comeca);