GT UI+

The first version to The GT UI+

Pada tanggal 18 Juni 2015. Lihat %(latest_version_link).

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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

getSpecialItems();
function getSpecialItems(){
    GM_xmlhttpRequest({
			method: 'GET',
			url: 'http://www.ghost-trappers.com/fb/setup.php?type=special',
			headers: {
				"Accept": "text/html",
				"Pragma": "no-cache",
				"Cache-Control": "no-cache"
			},
			onload: function(rD) {
                var text = rD.responseText;

                var result = text.match(/<div class="itemHeadline">[A-Za-z0-9'`._%+-\s]+/ig);

                for(var x = 0; x< result.length; x++){
                    result[x] = result[x].substr(result[x].indexOf('>')+1, result[x].lastIndexOf(' '));
                    result[x] = result[x].trim();
                }

				getAyumiShopItems(result);
			}
		});
};


function getAyumiShopItems(itemsInInventory){
	 GM_xmlhttpRequest({
			method: 'GET',
			url: 'http://www.ghost-trappers.com/fb/scotch_ninth_floor.php?page=shop&filterItemType=souvenir_set',
			headers: {
				"Accept": "text/html",
				"Pragma": "no-cache",
				"Cache-Control": "no-cache"
			},
			onload: function(rD) {
                var text = rD.responseText;
				var itemRGX = text.match(/<div class="itemInfo">(\n(.*?))*.?(<div class="seperatorLine">)/ig);
				
				var itemsHolder = [];
                for(var x = 0; x < itemRGX.length; x++){
                    
					var rgx = itemRGX[x];
					
					var itemNameRGX = rgx.match(/<div class="itemHeadline">\n*.*<\/div>|<div class="itemSpecialText">[A-Za-z0-9'`._%+-\s]+/ig);
					
					var itemCostRGX = rgx.match(/<div class="itemCurrency">(\n(.*?)<\/div>)*/ig);
					
					var itemName = itemNameRGX[0].match(/\s[A-Z0-9.-_\s]*?</ig);
					
					var itemName = itemName[0].substr(1, itemName[0].length-2);

					var item;
					
					if(itemsInInventory.indexOf(itemName) == -1){
						item = new Item(itemName);
					
						for(var y = 0; y < itemCostRGX.length; y++){
							var currency_price = itemCostRGX[y].match(/"PRICE - in(.*?)"|<div class="itemPrice">(.*?)<\/div>/ig);
							var currency = currency_price[0].substr(currency_price[0].indexOf('In')+3); 
							currency = currency.substr(0,currency.length-1); 
							
							if(currency == 'Great British Pounds, that goes without saying'){
								currency = "GBP"
							}
							
							var price = currency_price[1].match(/>[0-9,]*?</ig);
							price = price[0].substr(1,price[0].length-2); 
							
							try{
								price = parseInt(price.replace(/,/ig,''));
							}
							catch(err)
							{
								console.log('error parse price');
							}
							
							item.setCurrency(currency, price);
						}
						
						itemsHolder.push(item);
					}
                }

				constract_Table(itemsHolder);
			}
		});
}

function insertCommas(string,text){
    var result = text.toString();
    if (result.length > 3){
        for(var x = result.length-3; x>0; x-=3){
            result = result.substring(0, x) + string + result.substring(x, result.length);
        }  
    }

    return result;
}

function constract_Table(array){

	$('<div class="UserSricpt_container"></div>').appendTo('#header');
	
	var container = $('.UserSricpt_container');
	
	container.css('position','absolute');
	container.css('top','133%');
	container.css('left','-45%');
	container.css('color','#fff');
	
	for(var x = 0; x < array.length; x++){
		$('<a href="http://www.ghost-trappers.com/fb/scotch_ninth_floor.php?page=shop&filterItemType=souvenir_set" class="custom-item" id="item-'+x+'"></a>')
			.append($('<div class="itemName"></div>').html(array[x].getName()))
			.append($('<div class="itemCost"></div>').css('display', 'table'))
		.appendTo(container);
	
		var key = null;
		for(key in array[x].getItemCost())
		{
			$('#item-'+x).find('.itemCost').append($('<div class="itemCurrencyType"></div>').html('- '+key + " " +  array[x].getItemCost()[key]));       
		}
	}
	$('.UserSricpt_container').find('.custom-item').css({
		'display':'block',
		'color':'white',
		'position':'relative',
		'padding':'10px',
		'margin-bottom':'10px',
		'border-radius':'15px',
		'font-size':'14px',
		'width':'250px'
	});

	getCurrency(array);
}

function insertCommas(string,text){
    var result = text.toString();
    if (result.length > 3){
        for(var x = result.length-3; x>0; x-=3){
            result = result.substring(0, x) + string + result.substring(x, result.length);
        }  
    }

    return result;
}


function priceIn(dictionary, array){
    var elements = $(".UserSricpt_container")[0].childNodes;
    for(var x= 0; x < elements.length; x++){
        var currencyHolder = elements[x];
		
        var children = currencyHolder.childNodes;
		children = children[1].childNodes;
		var match = 0;
		for(var y = 0; y < children.length; y++){
			var temp = children[y].innerHTML;
			var priceIn = temp.substr(temp.indexOf('-')+2, temp.lastIndexOf(' ')-2).trim();
			var price = temp.substr(temp.lastIndexOf(' ')+1);

			try{
				dictionary[priceIn] = parseInt(dictionary[priceIn].replace(/,/ig,''));
			}
			catch(err)
			{
				// just skip this error!!!
			}
			
			children[y].innerHTML = ' - ' + priceIn +' '+ insertCommas(',',price) + '('+insertCommas(',',dictionary[priceIn])+')';
			
			if(dictionary[priceIn] >= array[x].getCurrency(priceIn)){
				
				if(match == children.length-1){

					$('.UserSricpt_container').find('#item-'+x).css({
						'background-color':'rgba(0, 128, 0, 0.2)',
						'border':'1px solid green',
						'box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px green',
						'-webkit-box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px green'
					});
				}
				
				match++;
			}
			else{
				
				$('.UserSricpt_container').find('#item-'+x).css({
					'background-color':'rgba(255, 0, 0, 0.2)',
					'border':'1px solid red',
					'box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px red',
					'-webkit-box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px red'
				});
				
			}
		}
    }

}

function getCurrency(array){
    GM_xmlhttpRequest({
			method: 'GET',
			url: 'http://www.ghost-trappers.com/fb/setup.php?type=currency',
			headers: {
				"Accept": "text/html",
				"Pragma": "no-cache",
				"Cache-Control": "no-cache"
			},
			onload: function(rD) {
                var text = rD.responseText;

                var result = text.match(/<div class="itemInfo">\n*.*<\/div>|<div class="itemSpecialText">[A-Za-z0-9'`._%+-\s]+/ig);
                var gbpHolder = document.getElementById('profile_gbp').innerHTML;

                var dictionary = [];
                for(var x = 0; x < result.length-1; x+=2){
                    var temp = result[x].match(/[A-Z0-9.-_\s]+>/ig);
                    var key = temp[0].substring(1, temp[0].indexOf('</')).trim();
                    var value = result[x+1].substring(result[x+1].indexOf('itemSpecialText'), result[x+1].indexOf('.'));
                    value = value.match(/[0-9]+/ig);
                    
                    dictionary[key] = parseInt(value);
                } 
                
                dictionary['GBP'] = gbpHolder;
                priceIn(dictionary, array);
			}
		});
};


var Item = function(name) {
  	this.name = name;
	this.dictionary = [];
};

Item.prototype.getName = function(){
	return this.name;
}

Item.prototype.setCurrency = function(currency, value){
	this.dictionary[currency] = value;
};

Item.prototype.getCurrency = function(currency){
	return this.dictionary[currency];
};

Item.prototype.getItemCost = function(){
	return this.dictionary;
}