More UI part2

The second part to The GT UI+

Verze ze dne 26. 08. 2015. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name       More UI part2
// @namespace  http://use.i.E.your.homepage/
// @version    1.0
// @description The second part to The GT UI+
// @match      http://www.ghost-trappers.com/fb/*
// @copyright  2015+, GTNoAPI
// @grant      GM_xmlhttpRequest
// ==/UserScript==

initUIv2();

function initUIv2(){
	GM_xmlhttpRequest({
			method: 'GET',
			url: 'https://gtnoapi.herokuapp.com/api/ghosts',
			headers: {
				"Accept": "application/json",
				"Pragma": "no-cache",
				"Cache-Control": "no-cache"
			},
			onload: function(rD) {
				$('.logText').each(function(){
					var ghostEncounter = $(this).find('a').html();
					var ghostInfo = getGhostByName(ghostEncounter, rD.response);
					if(ghostEncounter && ghostEncounter == ghostInfo.name){
						var perantEle;
						var childEle;
						if(ghostInfo.loot){

							var arrow= $('<div></div>').css({
								'width': '0' ,
								'height': '0',
								'border-top': '10px solid transparent',
								'border-bottom': '10px solid transparent',
								'border-left': '10px solid #223341',
								'position': 'absolute',
								'top': '10px',
								'right': '-10px',
							})

							childEle = $('<span></span>').css({
								'position': 'absolute',
								'top': '-14px',
								'right': '40px',
								'z-index': '9999999',
								'font-size': '14px',
								'display': 'none',
								'background-color': '#223341',
								'border': '1px solid #222',
								'border-radius': '7px',
								'padding': '10px',
								'min-width': '150px'

							}).html(ghostInfo.loot);


							 perantEle = $('<div>?</div>').css({
								 'cursor':'pointer',
								 'padding': '1px 4.5px',
								 'border-radius': '50%',
								 'background-color': 'black',
								 'color': 'white',
								 'float': 'right',
								 'font-weight': 'bold',
								 'position': 'relative'
							 });


							perantEle.hover(function(){
								if(childEle.css('display')=='none'){
									childEle.show();
								}
								else{
									childEle.hide();
								}
							});

							arrow.appendTo(childEle);
							childEle.appendTo(perantEle)
						}




						$(this).append(perantEle);
					}
				});
			}
		});
};


function getGhostByName(name, jsonTxt){
	
	var obj = jQuery.parseJSON(jsonTxt);
	var result = '';
	for(var x = 0; x < obj.length; x++){
		if(obj[x].name == name){
			var title = '';
			for(var y = 0; y < obj[x].loot.length; y++){
				title += obj[x].loot[y] + '<br />';
			}
			
			result = {
				'name':obj[x].name,
				'loot':title,
				'type':obj[x].type
			}
			
		}
		
	}
	
	
	return result;
}