Guest User

Untitled

a guest
May 30th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * Football Ultimate Cup Keyboards (FUCK)
  3. * v 0.4
  4. * Особенности:
  5. * - золотой гол считается за один, даже если это квадрипл, ибо нехуй
  6. */
  7. $(function(){
  8.     try { clearInterval(window.fuck_updater) } catch(e){}
  9.  
  10.     var $ = window.jQuery
  11.     ,   config_lines = $('.oppost-wrapper .post-message').html().split('<br>').filter(function(a){ return a.substr(0, 1) === '%' })
  12.     ,   config = config_lines.length === 0 ? undefined : config_lines[0].substr(1)
  13.     ,   config_team_names = config
  14.     ,   team_names = undefined === config ? [ '#1', '#2' ] : config_team_names.split('|').map(function(a){ return a.trim() })
  15.  
  16.     if(undefined === config){
  17.         return false
  18.     }
  19.  
  20.     window.fuck_updater = setInterval(function(){
  21.         var score = [ 0, 0 ]
  22.         ,   penalty = false
  23.         ,   ended = false
  24.  
  25.         $('.post-wrapper').each(function(n, el){
  26.             n++
  27.             el = $(el)
  28.  
  29.             var time_now = false
  30.             if(n <= 150){
  31.                 time_now = 1
  32.             } else if(n > 200 && n <= 350){
  33.                 time_now = 2
  34.             } else if(!ended && n > 350 && score[0] === score[1]){
  35.                 // до золотого гола
  36.                 time_now = 3
  37.             }
  38.  
  39.             var post_num = el.attr('id').replace(/[^0-9]/g, '')
  40.             ,   last_digit = parseInt( post_num.substr(-1) )
  41.             ,   is_double = post_num.substr(-1, 1) === post_num.substr(-2, 1)
  42.             ,   is_triple = is_double && ( post_num.substr(-1, 1) === post_num.substr(-3, 1) )
  43.             ,   is_quad = is_triple && ( post_num.substr(-1, 1) === post_num.substr(-4, 1) )
  44.             ,   team_now = (last_digit + (time_now === 1 ? 0 : 1)) % 2
  45.  
  46.             el.find('.postbtn-reply-href').html(post_num)
  47.             el.find('.post-message > span.fuck-message').remove()
  48.  
  49.             if(false !== time_now){
  50.                 // игра идёт
  51.                 if(true === penalty){
  52.                     // забит пенальти
  53.                     score[team_now]++
  54.                     el.find('.post-message').append(
  55.                         $('<span>')
  56.                         .addClass('fuck-message')
  57.                         .css('color', 'green')
  58.                         .append('<br><br>')
  59.                         .append('Гол! Пенальти забивает команда ' + team_names[team_now] + '. Счёт <strong>' + score[0] + ':' + score[1] + '</strong>.')
  60.                     )
  61.  
  62.                     penalty = false
  63.                     if(n > 350){ ended = true }
  64.                 } else if(is_triple && !is_quad){
  65.                     // назначен пенальти
  66.                     penalty = true
  67.                     el.find('.post-message').append(
  68.                         $('<span>')
  69.                         .addClass('fuck-message')
  70.                         .css('color', 'green')
  71.                         .append('<br><br>')
  72.                         .append('Назначается пенальти!')
  73.                     )
  74.                 } else if(is_double || is_quad){
  75.                     // гол немедленно
  76.                     score[team_now] += is_quad && time_now !== 3 ? 2 : 1
  77.                     el.find('.post-message').append(
  78.                         $('<span>')
  79.                         .addClass('fuck-message')
  80.                         .css('color', 'green')
  81.                         .append('<br><br>')
  82.                         .append((time_now === 3 ? 'Золотой гол' : (is_quad ? 'Два гола' : 'Гол')) + ' забивает команда ' + team_names[team_now] + '! Счёт <strong>' + score[0] + ':' + score[1] + '</strong>.')
  83.                     )
  84.                     if(n > 350){ ended = true }
  85.                 }
  86.             }
  87.         })
  88.  
  89.     }, 1000)
  90. })
Advertisement
Add Comment
Please, Sign In to add comment