@ -5,11 +5,21 @@ class CurrentUser {
}
fill_user ( ) {
fetch ( "https://tf2.pblr-nyk.pro/player_api/v1/current_user " , { credentials : "same-origin" , headers : { 'Cache-Control' : 'no-cache' } } )
fetch ( "https://tf2.pblr-nyk.pro/api/profile/current " , { credentials : "same-origin" , headers : { 'Cache-Control' : 'no-cache' } } )
. then ( response => response . json ( ) )
. catch ( err => {
if ( err . code == 429 ) {
$ ( "#Header_CurrentUser" ) . html ( "Слишком частые запросы с беку, обнови позднее позже!!" ) ;
$ ( "#Header_Logout" ) . html ( "" ) ;
return ;
}
$ ( "#Header_CurrentUser" ) . html ( "Ошибка получения данных профиля! " ) ;
$ ( "#Header_Logout" ) . html ( "(Обнови страницу для релога)" ) ;
return ;
} )
. then ( response => {
if ( "error" in response ) {
console . log ( response . error ) ;
if ( response == null || "error" in response ) {
//console.log(response.error);
$ ( "#Header_CurrentUser" ) . html ( "Ошибка получения данных профиля! " ) ;
$ ( "#Header_Logout" ) . html ( "(Обнови страницу для релога)" )
return ;
@ -37,30 +47,6 @@ class CurrentUser {
if ( check_cookie_name ( "steam64" ) ) {
var current_user = new CurrentUser ( ) ;
}
/ *
async function CheckCurrentUser ( ) {
if ( ! check_cookie_name ( "steam64" ) ) { return ; }
//$("#Header_CurrentUser").html(`Получение данных профиля с сервера... ПОДОЖДИ`);
/*await fetch("https:/ / tf2 . pblr - nyk . pro / player_api / v1 / current_user ", { credentials: " same - origin " , headers : { 'Cache-Control' : 'no-cache' } } )
. then ( response => response . json ( ) )
. then ( response => {
if ( "error" in response ) {
console . log ( response . error ) ;
} else {
$ ( "#Header_CurrentUser" ) . attr ( "href" , "#" ) ;
if ( response . ban ) {
$ ( "#Header_CurrentUser" ) . html ( ` Привет ${ response . steam_data . nickname } ! У меня хорошие новости! ` ) ;
$ ( "#Header_CurrentBan" ) . html ( "У тебя БАН! (нажми чтоб посмотреть его)" ) ;
} else {
$ ( "#Header_CurrentUser" ) . html ( ` Привет ${ response . steam_data . nickname } ! ` ) ;
}
$ ( "#Header_Logout" ) . html ( ` (нажми чтоб выйти) ` ) ;
$ ( "#profile_list" ) . remove ( ) ;
$ ( FillPlayerInfo ( response ) ) . appendTo ( "#profile_stats" ) ;
ReconstructVipSection ( response ) ;
}
} )
} * /
function check_cookie_name ( name ) {
var match = document . cookie . match ( new RegExp ( '(^| )' + name + '=([^;]+)' ) ) ;
@ -72,7 +58,7 @@ let captcha_error_div = `<div class="col" id="ModalCaptchaErrorText"><h6 style="
let ProfileLinkError_div = ` <div class="col" id="ProfileLinkIsNotFull"><h6 style="color: red;" id="profile_error">Долбаеб введи ссылку на профиль!</h6></div> ` ;
function CalculateVipEndDate ( permition ) {
return new Date ( ( permition [ "UNIX_TIMESTAMP(`reg_date`)" ] + permition . amount ) * 1000 ) ;
return new Date ( ( permition . u_timestamp + permition . amount ) * 1000 ) ;
}
function FillPlayerInfo ( data ) {
@ -272,6 +258,15 @@ function UNIX2FACTI_TIME(u_time) {
}
}
function human_name_impl_2 ( count , naming ) {
let number = Math . abs ( count ) % 100 ;
let number_post = number % 10 ;
if ( number > 10 && number < 20 ) { return naming [ 2 ] ; }
if ( number_post > 1 && number_post < 5 ) { return naming [ 1 ] ; }
if ( number_post == 1 ) { return naming [ 0 ] }
return naming [ 2 ] ;
}
function ReconstructVipSection ( data ) {
$ ( '#Modal_SelectPayMethod_Close' ) . click ( async function ( ev ) {
ev . preventDefault ( ) ;
@ -280,7 +275,7 @@ function ReconstructVipSection(data) {
$ ( '#Modal_SelectPayMethod_CheckVIP' ) . click ( async function ( ev ) {
ev . preventDefault ( ) ;
await fetch ( "https://tf2.pblr-nyk.pro/player_api/v1/player/permitions " , { credentials : "same-origin" , headers : { 'Cache-Control' : 'no-cache' } } )
await fetch ( "https://tf2.pblr-nyk.pro/api/profile/current?requests=permition " , { credentials : "same-origin" , headers : { 'Cache-Control' : 'no-cache' } } )
. then ( response => response . json ( ) )
. then ( response => {
if ( response . permition ) {
@ -307,43 +302,66 @@ function ReconstructVipSection(data) {
$ ( "#Modal_SelectPayMethod_ProfileLink" ) . attr ( "href" , data . steamids . community_url ) ;
$ ( "#Modal_SelectPayMethod_ProfileName" ) . html ( ` Вип будет выдан: ${ data . steam_data . nickname } ` ) ;
let price_array = new Array (
/ * l e t p r i c e _ a r r a y = n e w A r r a y (
[ "1 месяц" , 150 , "1 ключ" , "site_content/images/vip/VIP_1_MOUNTH.jpg" , "month" ] ,
[ "1 неделя" , 75 , "20 рефов" , "site_content/images/vip/VIP_7_DAYS.jpg" , "seven_day " ] ,
[ "1 неделя" , 75 , "20 рефов" , "site_content/images/vip/VIP_7_DAYS.jpg" , "week " ] ,
[ "1 день" , 20 , "5 рефов" , "site_content/images/vip/VIP_1_DAY.jpg" , "day" ] ,
[ "1 день" , 0 , "бесплатно" , "site_content/images/vip/freevip.jpg" , "free" ]
) ;
) ; * /
let vip_select ;
for ( const select in price_array ) {
for ( let price in api_prices ) {
price = api_prices [ price ] ;
vip_select = `
< div class = "col" >
< div class = "card" >
< img class = "card-img" src = "${price_array[select][3]}" alt = "${price_array[select][0] }" >
< img class = "card-img" src = "${price.img_url}" alt = "${price.human_duration }" >
< div class = "card-img-overlay d-flex flex-column" style = "background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.7))" >
< a href = "#" class = "stretched-link" id = "Section_VIP_buttons_${price_array[select][4] }" > < / a >
< a href = "#" class = "stretched-link" id = "Section_VIP_buttons_${price.period }" > < / a >
< div class = "mt-auto" >
< h5 class = "vip-card-text" > $ { price_array [ select ] [ 0 ] } < / h 5 >
< h6 class = "vip-card-text" > $ { price_array [ select ] [ 1 ] } Рублей < / h 6 >
< h6 class = "vip-card-text" > $ { price_array [ select ] [ 2 ] } < / h 6 >
< h5 class = "vip-card-text" > $ { price . human_duration } < / h 5 >
< h6 class = "vip-card-text" > $ { price . money_price } Рублей < / h 6 >
< h6 class = "vip-card-text" > $ { price . item_price } < / h 6 >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
`
$ ( vip_select ) . appendTo ( "#Section_VIP_buttons" ) ;
$ ( ` #Section_VIP_buttons_ ${ price_array [ select ] [ 4 ] } ` ) . click ( async function ( ev ) {
$ ( ` #Section_VIP_buttons_ ${ price . period } ` ) . click ( async function ( ev ) {
ev . preventDefault ( ) ;
if ( price_array [ select ] [ 4 ] != "free" ) {
if ( price . period != "free" ) {
$ ( "#Modal_SelectPayMethod_PayButtons" ) . show ( 0 ) ;
$ ( "#Modal_SelectPayMethod_GetFreeButtons" ) . hide ( 0 ) ;
$ ( "#Modal_SelectPayMethod_QIWI_Button" ) . attr ( "href" , QIWI_TRADE . replace ( "(AMOUNT)" , price_array [ select ] [ 1 ] ) . replace ( "(COMMENT)" , data . steamids . steam2 . replace ( ":" , "%3A" ) ) ) ;
$ ( "#Modal_SelectPayMethod_QIWI_Value" ) . html ( ` ${ price_array [ select ] [ 1 ] } Рублей ` ) ;
$ ( "#Modal_SelectPayMethod_QIWI_Button" ) . attr ( "href" , QIWI_TRADE . replace ( "(AMOUNT)" , price . money_price ) . replace ( "(COMMENT)" , data . steamids . steam2 . replace ( ":" , "%3A" ) ) ) ;
$ ( "#Modal_SelectPayMethod_QIWI_Value" ) . html ( ` ${ price . money_price } Рублей ` ) ;
$ ( "#Modal_SelectPayMethod_STEAM_Button" ) . attr ( "href" , STEAM_TRADE ) ;
$ ( "#Modal_SelectPayMethod_STEAM_Value" ) . html ( price_array [ select ] [ 2 ] ) ;
$ ( "#Modal_SelectPayMethod_STEAM_Value" ) . html ( price . item_price ) ;
try {
let value_qiwi = price . period in api_response . donate . month . statistic . qiwi ? api_response . donate . month . statistic . qiwi [ price . period ] : 0 ;
let value_name_1 = human_name_impl_2 ( value_qiwi , [ "раз" , "раза" , "раз" ] )
$ ( "#Modal_SelectPayMethod_DonateStatsValue_qiwi" ) . html ( ` ${ value_qiwi } ${ value_name_1 } ` ) ;
let value_steam = price . period in api_response . donate . month . statistic . steam ? api_response . donate . month . statistic . steam [ price . period ] : 0 ;
let value_name_2 = human_name_impl_2 ( value_steam , [ "раз" , "раза" , "раз" ] )
$ ( "#Modal_SelectPayMethod_DonateStatsValue_steam" ) . html ( ` ${ value_steam } ${ value_name_2 } ` ) ;
$ ( "#Modal_SelectPayMethod_DonateStatsText_FREE" ) . hide ( 0 ) ;
$ ( "#Modal_SelectPayMethod_DonateStatsValue" ) . show ( 0 ) ;
$ ( "#Modal_SelectPayMethod_DonateStatsText" ) . show ( 0 ) ;
} catch {
$ ( "#Modal_SelectPayMethod_DonateStatsValue" ) . hide ( 0 ) ;
$ ( "#Modal_SelectPayMethod_DonateStatsText" ) . hide ( 0 ) ;
}
} else {
$ ( "#Modal_SelectPayMethod_DonateStatsValue" ) . hide ( 0 ) ;
$ ( "#Modal_SelectPayMethod_DonateStatsText" ) . hide ( 0 ) ;
$ ( "#Modal_SelectPayMethod_PayButtons" ) . hide ( 0 ) ;
$ ( "#Modal_SelectPayMethod_GetFreeButtons" ) . show ( 0 ) ;
let value_free = "day" in api_response . donate . month . statistic . free ? api_response . donate . month . statistic . free . day : 0 ;
let value_free_naming = human_name_impl_2 ( value_free , [ "раз" , "раза" , "раз" ] )
$ ( "#Modal_SelectPayMethod_DonateStatsValue_free" ) . html ( ` ${ value_free } ${ value_free_naming } ` ) ;
$ ( "#Modal_SelectPayMethod_DonateStatsText_FREE" ) . show ( 0 ) ;
}
$ ( '#Modal_SelectPayMethod' ) . modal ( 'show' ) ;
return false ;
@ -353,7 +371,22 @@ function ReconstructVipSection(data) {
$ ( "#Modal_SelectPayMethod_GetFreeButton_Check" ) . click ( async function ( ev ) {
ev . preventDefault ( ) ;
alert ( "пошел нахуй" ) ;
await fetch ( "https://tf2.pblr-nyk.pro/api/profile/current/freevip" , { credentials : "same-origin" , headers : { 'Cache-Control' : 'no-cache' } , method : "POST" } )
. then ( response => response . json ( ) )
. then ( response => {
if ( response == 0 ) $ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( "У тебя уже есть права!" ) ;
else if ( response == 1 ) $ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( "Права выданы! Балдей!" ) ;
else if ( response > 1 ) $ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( ` Ты не можешь получить вип бесплатно, вернись через ${ UNIX2FACTI_TIME ( response ) } ` ) ;
else if ( response < 0 ) $ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( ` Наиграй на сервере еще ${ UNIX2FACTI_TIME ( response * - 1 ) } ` ) ;
else $ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( "Сегодня не твой день" ) ;
} )
. catch ( err => {
if ( err . code == 429 ) {
$ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( "Помедленее друг, не так сильно" ) ;
} else {
$ ( "#Modal_SelectPayMethod_GetFreeButton_Text" ) . html ( "Сегодня не твой день, друг..." ) ;
}
} ) ;
} ) ;
//secret egg