akif.yesilkaya1gmail.com / functions

function is_VIP(){
    var VIP=null;
    var page = location.href;
    if(page.indexOf('/World/Popmundo.aspx/Character')!==-1)
    {
        if(jQuery('#ppm-content > div.box.ofauto.charPresBox > h2').html().indexOf('/Static/Icons/VIPNameStar.png')!==-1)
        {
            VIP=true;
        }
        else
        {
            VIP=false;
        }
    }
    else
    {
        var character_id = character_id_in_page();
        if(character_id!==null)
        {
            var text = get_Data(ph()+'/World/Popmundo.aspx/Character/');
            if(text!==null)
            {
                if(text.indexOf('/Static/Icons/VIPNameStar.png')!==-1)
                {
                    VIP=true;
                }
                else
                {
                    VIP=False;
                }
            }
            else
            {
                give_notification(-1,"VIP'lık kontrol edilemedi!");
            }
        }
        else
        {
            give_notification(-1,"Karakter id bulunmuyor!");
        }
    }
    return VIP;
}
function ph(){
    return location.protocol+'//'+location.hostname;
}
function chracter_id_in_page(){
    var page = location.href;
    page = page.substring(page.lastIndexOf('/')+1).trim();
    if(!isNaN(page) && page!=="")
    {
        return parseInt(page);
    }
    else
    {
        return null;
    }
}
function get_Data(url){
    var text=null;
    jQuery.ajax({
        url: url,
        type: 'get',
        dataType: 'html',
        async: false,
        success: function(responseText) {
            text = unescape(responseText);
        }
    });
    return text;
}
function give_notification(type,message){
    type = type===1?"success":type===0?"normal":"error";
    if(getNumNotifications()===0)
    {
        displayNotifications();
    }
    jQuery("#notifications").append('<div class="notification-'+type+'">'+message+'</div>');
}
function displayNotifications() {
    jQuery("#notifications").removeClass("hidden").show();
}
function getNumNotifications() {
    return jQuery("#notifications > div").length;
}
function clearValues(a){
    for(var i = 0 ; i < a.length ; i++)
    {
        GM_deleteValue(a[i]);
    }
}
function getHealth(){
    var health=null;
    var page = location.href;
    var a = page.lastIndexOf('/');
    var b = page.indexOf('Character');
    if(a-9===b)
    {
        b = jQuery('#ppm-content > div.charMainValues > table > tbody > tr:nth-child(2) > td:nth-child(2) > div')[0].title;
        b = b.replace('%','').trim();
        if(!isNaN(b) && b!=="")
        {
            health = parseInt(b);
        }
    }
    else
    {
        var chracter_id = chracter_id_in_page();
        if(chracter_id!==null)
        {
            var text = getData(ph()+'/World/Popmundo.aspx/Character/'+chracter_id);
            if(text!==null)
            {
                a = text.indexOf('ctl00_cphLeftColumn_ctl00_imgHealth');
                a = text.indexOf('"sortkey">',a)+10;
                a = a.substring(a,a.indexOf('<')).trim();
                if(!isNaN(a) && a!=="")
                {
                    health = parseInt(a);
                }
                else
                {
                    give_notification(-1,"Sağlık seviyesi düzgün alınamadı.."+a);
                }
            }
            else
            {
                give_notification(-1,"Veri boş!");
            }
        }
        else
        {
            give_notification(-1,"Karakter id boş!");
        }
    }
    return health;
}
function getMood(){
    var mood = null;
    var page = location.href;var a = page.lastIndexOf('/');
    var b = page.indexOf('Character');
    if(a-9===b)
    {
        b = jQuery('#ppm-content > div.charMainValues > table > tbody > tr:nth-child(1) > td:nth-child(2) > div')[0].title;
        b = b.replace('%','').trim();
        if(!isNaN(b) && b!=="")
        {
            mood = parseInt(b);
        }
    }
    else
    {
        var chracter_id = chracter_id_in_page();
        if(chracter_id!==null)
        {
            var text = getData(ph()+'/World/Popmundo.aspx/Character/'+chracter_id);
            if(text!==null)
            {
                a = text.indexOf('ctl00_cphLeftColumn_ctl00_imgHealth');
                a = text.indexOf('"sortkey">',a)+10;
                a = a.substring(a,a.indexOf('<')).trim();
                if(!isNaN(a) && a!=="")
                {
                    mood = parseInt(a);
                }
                else
                {
                    give_notification(-1,"Ruh hali seviyesi düzgün alınamadı.."+a);
                }
            }
            else
            {
                give_notification(-1,"Veri boş!");
            }
        }
        else
        {
            give_notification(-1,"Karakter id boş!");
        }
    }
    return mood;
}
function getHealthOrMood(type){
    var value = null;
    if(type===0 || type===1)
    {
        var page = location.href;
        var a = page.lastIndexOf('/');
        var b = page.indexOf('Character');
        if(a-9===b)
        {
            b = jQuery('#ppm-content > div.charMainValues > table > tbody > tr:nth-child('+(type===0?2:1)+') > td:nth-child(2) > div')[0].title;
            b = b.replace('%','').trim();
            if(!isNaN(b) && b!=="")
            {
                value = parseInt(b);
            }
        }
        else
        {
            var chracter_id = chracter_id_in_page();
            if(chracter_id!==null)
            {
                var text = getData(ph()+'/World/Popmundo.aspx/Character/'+chracter_id);
                if(text!==null)
                {
                    a = text.indexOf('ctl00_cphLeftColumn_ctl00_img'+(type===0?"Health":"Mood"));
                    a = text.indexOf('"sortkey">',a)+10;
                    a = a.substring(a,a.indexOf('<')).trim();
                    if(!isNaN(a) && a!=="")
                    {
                        value = parseInt(a);
                    }
                    else
                    {
                        give_notification(-1,(type===0?"Sağlık":"Ruh hali")+" seviyesi düzgün alınamadı.."+a);
                    }
                }
                else
                {
                    give_notification(-1,"Veri boş!");
                }
            }
            else
            {
                give_notification(-1,"Karakter id boş!");
            }
        }
    }
    else
    {
        give_notification(-1,"Olmayan tür!");
    }
    return value;
}