Legend agar.io extension

Agario Mod - Legend,Ogario,Kitty,Old Skins,Animated Skins,Language Packs,Manual User Scripts,Chat,60++ Macros/Hotkeys(Tricksplit,Doublesplit,Quick Feeding,Popsplit,Auto Coins,Freeze Cell Macro,Auto respawn)

// ==UserScript==
// @name         Legend agar.io extension
// @namespace    Legend express agario mod
// @version      1.6
// @description  Agario Mod - Legend,Ogario,Kitty,Old Skins,Animated Skins,Language Packs,Manual User Scripts,Chat,60++ Macros/Hotkeys(Tricksplit,Doublesplit,Quick Feeding,Popsplit,Auto Coins,Freeze Cell Macro,Auto respawn)
// @homepage     http://www.legendmod.ml
// @author       Jimboy3100
// @license      MIT
// @icon         https://jimboy3100.github.io/banners/CropedImage128.gif
// @match        https://agar.io/*
// @match        https://play.google.com/*
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @connect      jimboy3100.github.io
// ==/UserScript==

// Legend Mod by Jimboy3100
/*MIT License*/

// Check location
if (location.host === "agar.io" && location.pathname === "/") {
var url = window.location.href;
localStorage.setItem("url", url);
    location.href = "https://agar.io/legendmod" + location.hash;
    return;
}
var modVersion = GM_info.script.version;
// Inject Legend
function inject(page) {
    var page = page.replace("</body>", "<script>init('" + modVersion + "');</script>" + "</body>");
    return page;
}
window.stop();
document.documentElement.innerHTML = "";

GM_xmlhttpRequest({
    method: "GET",
    url: "https://jimboy3100.github.io/LMexpress/LMexpress.html",
    onload: function(legend) {
        var doc = inject(legend.responseText);
        document.open();
        document.write(doc);
        setTimeout(function() {
            window.history.pushState(null, null, "/");
        }, 2000);

        document.close();
    }
});

if (location.host == "play.google.com") {
    window.close();
}

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}




//		$("#OpenuserScripts").after('<button id="SpecialDealsBtn" class="btn btn-primary btn" type="submit" onclick="BeforeSpecialDeals(); return false;" class="btn btn-primary btn-shop" style=" width: 100%; padding: 4px 0px 6px; margin-top: 2px;" data-itr="page_shop"><i class="fa fa-briefcase"></i>Special Deals</button>');		
var Lmagarversion = "";

window.LMGameConfiguration = $.ajax({
    type: "GET",
    url: "https://jimboy3100.github.io/agario/live/" + Lmagarversion + "GameConfiguration.json",
    async: false,
    datatype: "jsonp",
    success: function(info) {
        //var GameConfiguration = info;
    }
}).responseJSON;
//weird but it works....

setTimeout(function() {
    if (window.LMGameConfiguration == undefined) {
        window.LMGameConfiguration = $.ajax({
            type: "GET",
            url: "https://configs-web.agario.miniclippt.com/live/" + window.agarversion + "GameConfiguration.json",
            async: false,
            datatype: "jsonp",
            success: function(info) {
                //var GameConfiguration = info;
            }
        }).responseJSON;
    }
}, 3000);
setTimeout(function() {
    if (window.LMGameConfiguration != undefined) {
        window.LMAgarGameConfiguration = window.LMGameConfiguration;
        window.EquippableSkins = LMAgarGameConfiguration.gameConfig["Gameplay - Equippable Skins"];
    }
}, 5000);
if (window.agarioUID != null) {
	localStorage.setItem("agarioUID", window.agarioUID);
	localStorage.setItem("agarioID", window.agarioID);
}
else{
	window.agarioUID=localStorage.getItem("agarioUID");
	window.agarioID=localStorage.getItem("agarioID");	
}
setTimeout(function() {
window.MiniclipConfigDestination = "https://configs-web.agario.miniclippt.com/live/v12/2168/GameConfiguration.json";
SpecialDeals();
}, 8000);



	
		function SpecialDeals(){


if (window.agarioUID != null) {
LoadGameConfiguration();	
        $('#helloContainer').after('<div class="modal fade in" id="specialShopModal" aria-hidden="false" style="display: block;">' +
            '<div class="modal-backdrop fade in"></div>' +
            '<div class="modal-dialog" style="top: calc(50vh - 241.5px); width: 500px;">' +
            '<div class="modal-content">' +
            '<div id="CloseSpecialDeals" class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">' + Premadeletter113 + '</span></button>' +
            '<h4 class="modal-title" style="font-family: Roboto Condensed, sans-serif">Special deals</h4>' +
            '</div>' +
            '<div class="modal-body"><input type="text" class="form-control" id="agario_uid_input" placeholder="*UID (' + Premadeletter110 + ')" style="width: 85%; display: inline-block">' +
            '<div class="custom-checkbox" style="display: inline-block; margin-left: 10px; vertical-align: sub;"><input id="checkBoxLockUID" type="checkbox" disabled="disabled" style="width: 20px; height: 20px"><label for="cb1"></label></div>' +
            '<div class="bs-callout bs-callout-buy bs-callout-clickable" id="buy_starterpack">' +
            '<h4 id="dealtype" class="pull-left">purchase 125000 coins</h4><h5 class="pull-left"> <i> (' + Premadeletter111 + ')</i></h5>' +
            '<h4 id="dealcost" class="text-right">99.99 $</h4>' +
            '<div class="xpmt-buy-content" style="font-size: 13px; margin-top: -30px; float: left;font-weight: 700; background-color: rgba(0, 0, 0, 0.2); background-image: url(https://jimboy3100.github.io/banners/icondeal2.png);padding: 3px; align: middle; border-radius: 4px;width: 100%;height: 150px;z-index: 15;margin: auto;">' +
            '<div class="xpmt-money-stack" style="display: inline-block; margin-left: 70px; margin-top: 115px;"><span class="coins" style=""><b>125000 C</b></span></div>' +
            '<div class="xpmt-skins" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: -120px 310px; background-image: url(""); background-size: cover; border-color: #7c0001"></div>' +
            '</div>' +
            '</div><select id="ss-select-purchases" class="form-control" required="" style="margin-bottom: 30px"></select><select id="BuyDealCurrency" class="form-control" required="" style="display:inline; width: 40%; margin-top: -30px;"><option value="USD" data-itr="">USD</option><option value="EU" data-itr="">EU</option></select><color="red"> ' + Premadeletter112 + '</color>' +
            '<input type="text" class="form-control" id="GameConfigurationUrl" value = ' + window.MiniclipConfigDestination + ' placeholder="*Search any GameConfiguration.json destination" style="width: 85%; display: inline-block">' +
			'<p class="alert-warning text-center">' + Premadeletter116 + '<br>UID:<span class="alert-success" id="exp-uid">' + window.agarioUID + '</span> <font color="red" onclick=copy(window.agarioUID);><b><u>'+Premadeletter114+' UID</u></b></font><br>ID: ' + window.agarioID + ' .*UID ' + Premadeletter115 + '</p>' +
            '</div>' +
            '</div>' +
            '</div>' +
            '</div>');	
}
setTimeout(function() { populateSD();}, 1500);
		
		$("#GameConfigurationUrl").blur(function() {
			toastr["warning"]('Do not change this unless you know what it is');
			window.MiniclipConfigDestination=$("#GameConfigurationUrl").val();
			LoadGameConfiguration();
			setTimeout(function() { populateSD();}, 1500);
			});
        $("#CloseSpecialDeals").click(function() {
            
            $("#specialShopModal").remove();
        });
        $(".xpmt-buy-content").click(function() {
			toastr["warning"]('<div id="tutorial" style="background-image: url(https://jimboy3100.github.io/banners/v25toastricon.jpg); color:#018cf6; font-size:16px; text-align:center">' + Premadeletter90 +' v0.5<br>' + 'This is a BETA function, it may not work and you may loose your money' + '<br><font color="red">' + Premadeletter91a + '</font>' + '</br> <button class="btn btn-sm btn-primary" style="width: 100%; margin-top: 10px;border-color: darkblue;">' + Premadeletter24 + '</button><br><button class="btn btn-sm btn-warning btn-spectate btn-nodo-hideall" style="width: 100%;margin-top: 10px;">'+ Premadeletter25 + '</button></div>', "", { timeOut: 20000, extendedTimeOut: 20000 }).css("width", "300px");	
			$(".btn.btn-sm.btn-primary").click(function () { buydeals(); });	
        });
        $('#agario_uid_input').blur(function() {
            if (letterCount($('#agario_uid_input').val(), '-', true) == 4) {
                document.getElementById("checkBoxLockUID").checked = true;
                toastr["info"](Premadeletter92).css("width", "250px");
                $("#exp-uid").text($('#agario_uid_input').val());
            } else {
                document.getElementById("checkBoxLockUID").checked = false;
                toastr["info"](Premadeletter93).css("width", "210px");	
                $("#exp-uid").text(window.agarioUID);
            }
        });		
        $('#ss-select-purchases').on('change', function() {
            console.log(this.value);
			findSDescription();
            $(".xpmt-skins2").remove();
            $(".xpmt-money-stack").text($("#ss-select-purchases option:selected").text().substr(0, $("#ss-select-purchases option:selected").text().indexOf('_')) + " C");
            $("#dealcost").text($("#ss-select-purchases option:selected").text().split('=').pop());

            var textcropped1 = $("#ss-select-purchases option:selected").text().split('1_skin_').pop();
            textcropped1 = textcropped1.substr(0, textcropped1.indexOf(' ')).replace(' ', '');
            textcropped1 = textcropped1.charAt(0).toUpperCase() + textcropped1.slice(1);
            $(".xpmt-skins").css('background-image', 'url("https://configs-web.agario.miniclippt.com/live/v12/2168/' + textcropped1 + '.png")');
            setTimeout(function() {
                if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal7") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Blueberry_Face.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal15") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Hot_Dog.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal17") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Comet.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal18") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Comet.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal21") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Jar_Brain.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal22") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Jar_Brain.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal25") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Laika.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal26") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Laika.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal27") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/pig.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal36") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/UFO.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal41") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/zombie.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal42") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/zombie.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal52") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Tiger_Pattern.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal53") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/toon.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.dailydeal54") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/toon.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.starterpack3") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/pig.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.starterpack4") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Blueberry_Face.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.starterpack6") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Tomato_Face.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.starterpack7") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Comet.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.boosterpromo3") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/monthly_web_husky.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack1") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_wendigo.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack2") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_red_fiend.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack3") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_wendigo.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_red_fiend.png); background-size: cover; border-color: #7c0001"></div>');
                    $(".xpmt-money-stack").text("1800 DNA");
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack4") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/anime_skull_bow.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack5") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/anime_skull_bow.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack7") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/anime_power_ninja.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack10") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_wendigo.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_night_hunter.png); background-size: cover; border-color: #7c0001"></div>');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack11") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/samurai_war_mask.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/samurai_skull_samurai.png); background-size: cover; border-color: #7c0001"></div>');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack12") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/birthday_2017_2_rabid.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/birthday_2017_2_delighted.png); background-size: cover; border-color: #7c0001"></div>');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack13") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/pet_balls_elephant.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack14") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/samurai_war_mask.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack15") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/samurai_rogue_samurai.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack16") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/samurai_war_mask.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/samurai_rogue_samurai.png); background-size: cover; border-color: #7c0001"></div>');
                    $(".xpmt-money-stack").text("1800 DNA");
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.zodiacpromo") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/zodiac_2017_skin_scorpio.png ")');
                    $(".xpmt-money-stack").text("800 DNA");
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.zodiacpromoweb") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/zodiac_2017_skin_scorpio.png ")');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.collector2") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/birthday_sir.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/ChilliPepper.png); background-size: cover; border-color: #7c0001"></div>');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.collector4") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/Rooster.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/birthday_doge.png); background-size: cover; border-color: #7c0001"></div>');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack17") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/anime_skull_bow.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/anime_giant_human.png); background-size: cover; border-color: #7c0001"></div>');
                    $(".xpmt-money-stack").text("1800 DNA");
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.promotionpack18") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/anime_skull_bow.png ")');
                    $('.xpmt-skins').after('<div class="xpmt-skins2" style="width: 110px;height: 110px;background: no-repeat 50% 50%;background-size: 106px;border-radius: 50%; border: 3px solid #708090;margin: 35px 350px; background-image: url(https://configs-web.agario.miniclippt.com/live/v12/2168/anime_giant_human.png); background-size: cover; border-color: #7c0001"></div>');
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.potionpromo3") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_wendigo.png ")');
                    $(".xpmt-money-stack").text("16000 C+ 1800 DNA");
                } else if ($('#ss-select-purchases').val() == "com.miniclip.agar.io.potionpromo6") {
                    $(".xpmt-skins").css('background-image', 'url(" https://configs-web.agario.miniclippt.com/live/v12/2168/moonlight_wendigo.png ")');
                    $(".xpmt-money-stack").text("7000 C+ 800 DNA");
                }
            }, 500);
        });	
}
//EU OR USD
function buydeals(){
   $.ajax({
        type: "GET",
        url: "https://payments.agario.miniclippt.com/pay/"+$("#exp-uid").text()+"/"+$( "#ss-select-purchases option:selected" ).val()+"/"+$("#BuyDealCurrency").val(),
        datatype: "json",
        success: function(info) {
        return buytoken=info.iframe_url;
			}
		});
setTimeout(function() {		
	window.open(buytoken, "PopupWindow", "width=600,height=600,scrollbars=yes,resizable=no");
}, 3000);
}

            function populateSD(){
			var select = document.getElementById("ss-select-purchases");
                for(i=0;i<GameConfiguration.gameConfig["Wallet - In-App Purchases"].length;i++){
                    if(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].priceTier=="2"){
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId+" = 1.99 $", GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}
                    else if(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].priceTier=="5"){
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId+" = 4.99 $", GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}
                    else if(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].priceTier=="10"){
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId+" = 9.99 $", GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}						
                    else if(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].priceTier=="20"){
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId+" = 19.99 $", GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}
                    else if(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].priceTier=="50"){
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId+" = 49.99 $", GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}
                    else if(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].priceTier=="60"){
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId+" = 99.99 $", GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}					
                    else {
                    select.options[select.options.length] = new Option(GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].bundleId, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id, GameConfiguration.gameConfig["Wallet - In-App Purchases"][i].id);
					}					
				}

            }

            function findSDescription(){
			var findSDiconlocationString2=$("#ss-select-purchases option:selected").text().split('=').pop();
			findSDiconlocationString2=$("#ss-select-purchases option:selected").text().replace(findSDiconlocationString2, '');
			findSDiconlocationString2=findSDiconlocationString2.replace(' =', '');	
			var select = document.getElementById("ss-select-purchases");
                for(i=0;i<GameConfiguration.gameConfig["Visual - Bundles"].length;i++){
					
                    if(GameConfiguration.gameConfig["Visual - Bundles"][i].bundleId==findSDiconlocationString2){
						console.log("bundleId found");
						var findSDicondescriptionString=GameConfiguration.gameConfig["Visual - Bundles"][i].description;
						if (typeof findSDicondescriptionString === 'string' || findSDicondescriptionString instanceof String){
							// it's a string
							
							console.log(findSDicondescriptionString);
							if(findSDicondescriptionString!="na"){		
								findSDicondescriptionString=findSDicondescriptionString.replace('_',' ');	
								findSDicondescriptionString=findSDicondescriptionString.replace('_',' ');
								findSDicondescriptionString=findSDicondescriptionString.replace('_',' ');
								findSDicondescriptionString=findSDicondescriptionString.replace('_',' ');
								findSDicondescriptionString=findSDicondescriptionString.replace('_',' ');
								findSDicondescriptionString=findSDicondescriptionString.replace(' name','');
								$("#dealtype").text(findSDicondescriptionString);
							}
							else{
								console.log("no description");
								var findSDicondescriptionString=$('#ss-select-purchases').val();
								findSDicondescriptionString = findSDicondescriptionString.replace('com.miniclip.agar.io.','');
								findSDicondescriptionString = findSDicondescriptionString.charAt(0).toUpperCase() + findSDicondescriptionString.slice(1);
								$("#dealtype").text(findSDicondescriptionString);
							}
						}
						else{
						console.log("description is not a String");
						$("#dealtype").text("Unknown");
						}	
					}
				}
			}			
function letterCount(string, letter, caseSensitive) {
    var count = 0;
    if ( !caseSensitive) {
        string = string.toUpperCase();
        letter = letter.toUpperCase();
    }
    for (var i=0, l=string.length; i<string.length; i += 1) {
        if (string[i] === letter) {
            count += 1;
        }
    }
    return count;
}

function LoadGameConfiguration(){
	GameConfiguration={};
		$.ajax({
        type: "GET",
        url: window.MiniclipConfigDestination,
        datatype: "json",
        success: function(info) {
        return GameConfiguration=info;
			}
		});		
}

function removeEmojis (string) {
  var regex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;
  return string.replace(regex, '');
}
function Video(src, append) {
    var v = document.createElement("video");
    if (src != "") {
        v.src = src;
    }
    if (append == true) {
        document.body.appendChild(v);
    }
    return v;
}
function checkVideos(a, b) {
    checkVideos1(a);
    //setTimeout(function() {
    if (window.videoJustWatchPro[a].readyState == 4) {
        if (!window.videoJustWatchPro[a].playing) {
            window.videoJustWatchPro[a].play();
            setTimeout(function() {
                checkVideos2(a, b);
            }, 2000);
        };

    }
    //}, 2000);
    return true;
}

function checkVideos2(a, b) {
		//console.log("b is: "+ b);
    for (i = 0; i < legendmod3.top5.length - 1; i++) {

        if (i.nick == b) {
            //legendmod3.setTarget(i.id);	
			
            if ($("#nick").val() != b) {
                if (legendmod5.videoSkinsMusic == true) {
                    window.videoJustWatchProflag2[b] = false;
                    if (legendmod3.calculateMapSector(legendmod3.top5[i].x, legendmod3.top5[i].y) == legendmod3.currentSector && legendmod3.currentSector == "C3") {
						//console.log("volume 0, stage 0");
                        window.videoJustWatchPro[a].volume = 1;
                        window.videoJustWatchProflag2[b] = true;
                    } else {
						//console.log("volume 0, stage 1");
                        window.videoJustWatchPro[a].volume = 0;
                    }
                }
				else{
					//console.log("volume 0, stage 2");
					window.videoJustWatchPro[a].volume = 0;
				}
            }
        }

    }
    if ($("#nick").val() != b) {
        checkvideoJustWatchProflag2(a,b);
    }
}

function checkvideoJustWatchProflag2(a,b){
	
	if (!window.videoJustWatchProflag2[b]){
		//console.log("volume 0, stage 3");
		window.videoJustWatchPro[a].volume = 0;
	}
}
function checkVideos1(a){
	
	if (!videoJustWatchProflag[a]){
		console.log("video skins activated");
		window.videoJustWatchPro[a] = document.createElement("video"); // create a video element
		window.videoJustWatchPro[a].crossOrigin = 'anonymous';
		window.videoJustWatchPro[a].src = a;	
		window.videoJustWatchProflag[a]=true;
	}
};	

function checkVideos3(o){
	if(o.readyState > 0) {
		var minutes = parseInt(o.duration / 60, 10);
		var seconds = o.duration % 60;
		if (minutes>5){
			toastr["warning"]("<b>[SERVER]:</b> " +"Avoid using video skins bigger than 6 minutes");
		}
	}		
}

var PointQuadTree=(function(){"use strict";var GROWTH=1.1;function Node(x,y,w,h){this.x=x;this.y=y;this.w=w;this.h=h;this.points=[];this.children=null;}
Node.prototype={containsPoint:function(point){return point.x>=this.x&&point.x<=this.x+this.w&&point.y>=this.y&&point.y<=this.y+this.h;},overlaps:function(aabb){return aabb.x<this.x+this.w&&aabb.x+aabb.w>this.x&&aabb.y<this.y+this.h&&aabb.y+aabb.h>this.y;},insert:function(point,maxPoints){if(this.children!=null){var col=point.x>this.x+this.w/2;var row=point.y>this.y+this.h/2;this.children[col+row*2].insert(point,maxPoints*GROWTH);}else{this.points.push(point);if(this.points.length>maxPoints&&this.w>1){this.split(maxPoints);}}},some:function(aabb,test){if(this.children!=null){for(var i=0;i<this.children.length;++i){var child=this.children[i];if(child.overlaps(aabb)&&child.some(aabb,test)){return true;}}}else{for(var i=0;i<this.points.length;++i){var point=this.points[i];if(Node.prototype.containsPoint.call(aabb,point)&&test(point)){return true;}}}
return false;},split:function(maxPoints){this.children=[];var halfW=this.w/2;var halfH=this.h/2;for(var y=0;y<2;++y){for(var x=0;x<2;++x){var px=this.x+x*halfW;var py=this.y+y*halfH;this.children.push(new Node(px,py,halfW,halfH));}}
var oldPoints=this.points;this.points=[];var midX=this.x+halfW;var midY=this.y+halfH;for(var i=0;i<oldPoints.length;++i){var point=oldPoints[i];var col=point.x>midX;var row=point.y>midY;this.children[col+row*2].insert(point,maxPoints*GROWTH);}},clear:function(){if(this.children!=null){for(var i=0;i<4;++i){this.children[i].clear();}
this.children.length=0;this.children=null;}
this.points.length=0;this.points=null;}};function PointQuadTree(x,y,w,h,maxPoints){this.root=new Node(x,y,w,h);this.maxPoints=maxPoints;}
PointQuadTree.prototype={clear:function(){this.root.clear();},insert:function(point){if(!this.root.containsPoint(point))return;this.root.insert(point,this.maxPoints);},some:function(aabb,test){return this.root.some(aabb,test);}};return PointQuadTree;})();

var regionobj = {
        'AF': "JP-Tokyo",
        'AX': "EU-London",
        'AL': "EU-London",
        'DZ': "EU-London",
        'AS': "SG-Singapore",
        'AD': "EU-London",
        'AO': "EU-London",
        'AI': "US-Atlanta",
        'AG': 'US-Atlanta',
        'AR': "BR-Brazil",
        'AM': 'JP-Tokyo',
        'AW': 'US-Atlanta',
        'AU': "SG-Singapore",
        'AT': "EU-London",
        'AZ': "JP-Tokyo",
        'BS': 'US-Atlanta',
        'BH': "JP-Tokyo",
        'BD': "JP-Tokyo",
        'BB': "US-Atlanta",
        'BY': "EU-London",
        'BE': "EU-London",
        'BZ': "US-Atlanta",
        'BJ': "EU-London",
        'BM': "US-Atlanta",
        'BT': "JP-Tokyo",
        'BO': "BR-Brazil",
        'BQ': "US-Atlanta",
        'BA': "EU-London",
        'BW': "EU-London",
        'BR': "BR-Brazil",
        'IO': "JP-Tokyo",
        'VG': "US-Atlanta",
        'BN': "JP-Tokyo",
        'BG': "EU-London",
        'BF': 'EU-London',
        'BI': 'EU-London',
        'KH': 'JP-Tokyo',
        'CM': "EU-London",
        'CA': 'US-Atlanta',
        'CV': "EU-London",
        'KY': 'US-Atlanta',
        'CF': "EU-London",
        'TD': "EU-London",
        'CL': "BR-Brazil",
        'CN': "CN-China",
        'CX': "JP-Tokyo",
        'CC': "JP-Tokyo",
        'CO': 'BR-Brazil',
        'KM': "EU-London",
        'CD': "EU-London",
        'CG': 'EU-London',
        'CK': "SG-Singapore",
        'CR': "US-Atlanta",
        'CI': "EU-London",
        'HR': "EU-London",
        'CU': "US-Atlanta",
        'CW': "US-Atlanta",
        'CY': "JP-Tokyo",
        'CZ': "EU-London",
        'DK': "EU-London",
        'DJ': "EU-London",
        'DM': "US-Atlanta",
        'DO': 'US-Atlanta',
        'EC': 'BR-Brazil',
        'EG': "EU-London",
        'SV': "US-Atlanta",
        'GQ': "EU-London",
        'ER': 'EU-London',
        'EE': "EU-London",
        'ET': "EU-London",
        'FO': "EU-London",
        'FK': "BR-Brazil",
        'FJ': "SG-Singapore",
        'FI': "EU-London",
        'FR': 'EU-London',
        'GF': "BR-Brazil",
        'PF': "SG-Singapore",
        'GA': "EU-London",
        'GM': "EU-London",
        'GE': "JP-Tokyo",
        'DE': "EU-London",
        'GH': 'EU-London',
        'GI': "EU-London",
        'GR': 'EU-London',
        'GL': "US-Atlanta",
        'GD': "US-Atlanta",
        'GP': "US-Atlanta",
        'GU': "SG-Singapore",
        'GT': 'US-Atlanta',
        'GG': 'EU-London',
        'GN': 'EU-London',
        'GW': "EU-London",
        'GY': "BR-Brazil",
        'HT': "US-Atlanta",
        'VA': "EU-London",
        'HN': 'US-Atlanta',
        'HK': 'JP-Tokyo',
        'HU': "EU-London",
        'IS': "EU-London",
        'IN': "JP-Tokyo",
        'ID': "JP-Tokyo",
        'IR': "JP-Tokyo",
        'IQ': "JP-Tokyo",
        'IE': "EU-London",
        'IM': "EU-London",
        'IL': "JP-Tokyo",
        'IT': "EU-London",
        'JM': "US-Atlanta",
        'JP': "JP-Tokyo",
        'JE': "EU-London",
        'JO': "JP-Tokyo",
        'KZ': "JP-Tokyo",
        'KE': "EU-London",
        'KI': "SG-Singapore",
        'KP': "JP-Tokyo",
        'KR': "JP-Tokyo",
        'KW': "JP-Tokyo",
        'KG': 'JP-Tokyo',
        'LA': 'JP-Tokyo',
        'LV': 'EU-London',
        'LB': "JP-Tokyo",
        'LS': 'EU-London',
        'LR': "EU-London",
        'LY': "EU-London",
        'LI': 'EU-London',
        'LT': "EU-London",
        'LU': "EU-London",
        'MO': 'JP-Tokyo',
        'MK': 'EU-London',
        'MG': "EU-London",
        'MW': "EU-London",
        'MY': 'JP-Tokyo',
        'MV': "JP-Tokyo",
        'ML': "EU-London",
        'MT': "EU-London",
        'MH': 'SG-Singapore',
        'MQ': "US-Atlanta",
        'MR': "EU-London",
        'MU': "EU-London",
        'YT': "EU-London",
        'MX': "US-Atlanta",
        'FM': "SG-Singapore",
        'MD': 'EU-London',
        'MC': "EU-London",
        'MN': 'JP-Tokyo',
        'ME': 'EU-London',
        'MS': "US-Atlanta",
        'MA': "EU-London",
        'MZ': "EU-London",
        'MM': "JP-Tokyo",
        'NA': "EU-London",
        'NR': 'SG-Singapore',
        'NP': "JP-Tokyo",
        'NL': "EU-London",
        'NC': 'SG-Singapore',
        'NZ': "SG-Singapore",
        'NI': "US-Atlanta",
        'NE': "EU-London",
        'NG': 'EU-London',
        'NU': 'SG-Singapore',
        'NF': "SG-Singapore",
        'MP': "SG-Singapore",
        'NO': "EU-London",
        'OM': "JP-Tokyo",
        'PK': "JP-Tokyo",
        'PW': "SG-Singapore",
        'PS': "JP-Tokyo",
        'PA': "US-Atlanta",
        'PG': "SG-Singapore",
        'PY': "BR-Brazil",
        'PE': "BR-Brazil",
        'PH': "JP-Tokyo",
        'PN': "SG-Singapore",
        'PL': "EU-London",
        'PT': "EU-London",
        'PR': "US-Atlanta",
        'QA': "JP-Tokyo",
        'RE': "EU-London",
        'RO': "EU-London",
        'RU': "RU-Russia",
        'RW': "EU-London",
        'BL': "US-Atlanta",
        'SH': "EU-London",
        'KN': 'US-Atlanta',
        'LC': 'US-Atlanta',
        'MF': 'US-Atlanta',
        'PM': "US-Atlanta",
        'VC': "US-Atlanta",
        'WS': 'SG-Singapore',
        'SM': 'EU-London',
        'ST': "EU-London",
        'SA': "EU-London",
        'SN': "EU-London",
        'RS': "EU-London",
        'SC': "EU-London",
        'SL': "EU-London",
        'SG': "JP-Tokyo",
        'SX': 'US-Atlanta',
        'SK': "EU-London",
        'SI': "EU-London",
        'SB': "SG-Singapore",
        'SO': "EU-London",
        'ZA': 'EU-London',
        'SS': "EU-London",
        'ES': "EU-London",
        'LK': 'JP-Tokyo',
        'SD': "EU-London",
        'SR': "BR-Brazil",
        'SJ': 'EU-London',
        'SZ': "EU-London",
        'SE': "EU-London",
        'CH': "EU-London",
        'SY': "EU-London",
        'TW': "JP-Tokyo",
        'TJ': "JP-Tokyo",
        'TZ': "EU-London",
        'TH': "JP-Tokyo",
        'TL': 'JP-Tokyo',
        'TG': "EU-London",
        'TK': 'SG-Singapore',
        'TO': "SG-Singapore",
        'TT': "US-Atlanta",
        'TN': "EU-London",
        'TR': "TK-Turkey",
        'TM': "JP-Tokyo",
        'TC': "US-Atlanta",
        'TV': 'SG-Singapore',
        'UG': "EU-London",
        'UA': "EU-London",
        'AE': "EU-London",
        'GB': "EU-London",
        'US': "US-Atlanta",
        'UM': "SG-Singapore",
        'VI': "US-Atlanta",
        'UY': "BR-Brazil",
        'UZ': 'JP-Tokyo',
        'VU': "SG-Singapore",
        'VE': "BR-Brazil",
        'VN': "JP-Tokyo",
        'WF': "SG-Singapore",
        'EH': "EU-London",
        'YE': "JP-Tokyo",
        'ZM': "EU-London",
        'ZW': "EU-London"
    }