cloddy / HA Check

// ==UserScript==
// @name HA Check
// @description s
// @include     *://rink.hockeyapp.net/*
// @version     0.1
// @author Gleb
// ==/UserScript==


/*
Говнокод, работает и ладно.
*/


$(function(){	
	$('li:contains("Last Added")').parent().append('<div class="input-append" style="float:right"><input class="search-query" id="email" placeholder="E-Mail" type="text"><input class="btn btn-ha-primary" type="submit" id="kn" value="Найти"></div>');

	$('body').append('<style>progress {appearance: none;-webkit-appearance: none;box-shadow:  0px 1px 2px 0px rgba(0, 0, 0, .2);width:400px;height:25px;}progress::-webkit-progress-bar {background: white;}progress::-webkit-progress-value {background: #0084bc;}progress[value]::-webkit-progress-value {background-image: #0084bc,-webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25));background-size:50px 25px, 100% 100%, 100% 100%;}</style>');

   
    

	
$('#kn').click(function(){
	//var num = 34;
	var num = $('.pagination').find('li:last').prev().text(); //eq(-2) не заработало
	var i = 0;

	var test = 23;
	//var al = 199;
	var al = parseInt($('.pad-top').text().replace(/\D+/g,""));
	var email = $('#email').attr("value");
	if(email === '') return false;
	 $('tbody.page').fadeOut();
	 $('.pagination').fadeOut();
	 $('.pagination').html('<progress id="prog" max="'+al+'" value="0"></progress>');
	 $('.pagination').fadeIn();
 $('.pull-right').html('no');
	
	
	for(var page = 1;page <= num; page++)
	{
	
	var url = 'https://rink.hockeyapp.net/manage/teams/107069/team_users';
	
	if($('.pull-right').html() != 'ok') {
	$.get(url, {page: page}, function (data) {
		$('tbody.page', data).find('tr.user').each(function(){
		i++;
		 console.log(i+') '+$(this).attr('data-member-email'));
		$('#prog').val(i);
			
		 if($(this).attr('data-member-email') == email) {
			  $('.pagination').fadeOut();
			 $('tbody.page').fadeIn();
			 $('tbody.page').html('<tr class="user" onView="alert(num)" rel="'+$(this).attr('rel')+'">'+$(this).html()+'</tr>'); // костылим
			 $('.pull-right').html('ok');
			 return true;
			
		 }

		 });
		 	
		});
	}
	
	
	  

	}
	
	

});

});