View difference between Paste ID: rnLsd3PD and NKdT4DVW
SHOW: | | - or go back to the newest paste.
1
/*
2
* Football Ultimate Cup Keyboards (FUCK)
3-
* v 0.5
3+
* v 0.7
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
	$('body')
21
	.append(
22
		$('<style>')
23-
		.html('.fuck-scoreboard{position:fixed;bottom:0px;left:0px;width:270px;height:130px;border:1px solid #ccc;padding:10px 5px;background-color:#ddd;text-align:center;}.fuck-scoreboard-one{float:left;width:125px;height:100%;}.fuck-scoreboard-one-score{height:90px;font-size:45px;font-weight:bold;line-height:90px;}.fuck-scoreboard-one-team{height:20px;color:#888;font-size:14px;line-height:20px;}')
23+
		.html('.fuck-message{color:green;}.fuck-scoreboard{position:fixed;bottom:0px;left:0px;width:270px;height:130px;border:1px solid #ccc;padding:10px 5px;background-color:#ddd;text-align:center;}.fuck-scoreboard-one{float:left;width:125px;height:100%;}.fuck-scoreboard-one-score{height:90px;font-size:45px;font-weight:bold;line-height:90px;}.fuck-scoreboard-one-team{height:20px;color:#888;font-size:14px;line-height:20px;}')
24
	)
25
	.append(
26
		$('<div>')
27
		.addClass('fuck-scoreboard')
28
		.append(
29
			$('<div>')
30
			.addClass('fuck-scoreboard-one')
31
			.append(
32
				$('<div>')
33
				.addClass('fuck-scoreboard-one-score')
34
				.html('0')
35
			)
36
			.append(
37
				$('<div>')
38
				.addClass('fuck-scoreboard-one-team')
39
				.html(team_names[0])
40
			)
41
		)
42
		.append(
43
			$('<div>')
44
			.addClass('fuck-scoreboard-one')
45
			.append(
46
				$('<div>')
47
				.addClass('fuck-scoreboard-one-score')
48
				.html('0')
49
			)
50
			.append(
51
				$('<div>')
52
				.addClass('fuck-scoreboard-one-team')
53
				.html(team_names[1])
54
			)
55
		)
56
	)
57
58
	window.fuck_updater = setInterval(function(){
59
		var score = [ 0, 0 ]
60
		,	penalty = false
61
		,	ended = false
62
63
		$('.post-wrapper').each(function(n, el){
64
			n++
65
			el = $(el)
66
67
			var time_now = false
68
			if(n <= 150){
69
				time_now = 1
70
			} else if(n > 200 && n <= 350){
71
				time_now = 2
72
			} else if(!ended && n > 350 && score[0] === score[1]){
73
				// до золотого гола
74
				time_now = 3
75
			}
76
77
			var post_num = el.attr('id').replace(/[^0-9]/g, '')
78
			,	last_digit = parseInt( post_num.substr(-1) )
79
			,	is_double = post_num.substr(-1, 1) === post_num.substr(-2, 1)
80
			,	is_triple = is_double && ( post_num.substr(-1, 1) === post_num.substr(-3, 1) )
81
			,	is_quad = is_triple && ( post_num.substr(-1, 1) === post_num.substr(-4, 1) )
82
			,	team_now = (last_digit + (time_now === 1 ? 0 : 1)) % 2
83
84
			el.find('.postbtn-reply-href').html(post_num)
85
			el.find('.post-message > span.fuck-message').remove()
86
87
			if(false !== time_now){
88
				// игра идёт
89
				if(true === penalty){
90
					// забит пенальти
91
					score[team_now]++
92
					el.find('.post-message').append(
93
						$('<span>')
94
						.addClass('fuck-message')
95-
						.css('color', 'green')
95+
96
						.append('Гол! Пенальти забивает команда ' + team_names[team_now] + '. Счёт ' + team_names[0] + ' <strong>' + score[0] + ':' + score[1] + '</strong> ' + team_names[1] + '.')
97
					)
98
99
					penalty = false
100
					if(n > 350){ ended = true }
101
				} else if(is_triple && !is_quad){
102
					// назначен пенальти
103
					penalty = true
104
					el.find('.post-message').append(
105
						$('<span>')
106
						.addClass('fuck-message')
107
						.append('<br><br>')
108-
						.css('color', 'green')
108+
109
					)
110
				} else if(is_double || is_quad){
111
					// гол немедленно
112
					score[team_now] += is_quad && time_now !== 3 ? 2 : 1
113
					el.find('.post-message').append(
114
						$('<span>')
115
						.addClass('fuck-message')
116
						.append('<br><br>')
117
						.append((time_now === 3 ? 'Золотой гол' : (is_quad ? 'Два гола' : 'Гол')) + ' забивает команда ' + team_names[team_now] + '! Счёт ' + team_names[0] + ' <strong>' + score[0] + ':' + score[1] + '</strong> ' + team_names[1] + '.')
118-
						.css('color', 'green')
118+
119
					if(n > 350){ ended = true }
120
				}
121
			}
122
123
			if(el.find('.post-message').text().replace(/[^0-9a-zа-я\ ]/gi, '').match(/спасибо скрипткун/i)){
124
				el.find('.post-message').append(
125
					$('<span>')
126
					.addClass('fuck-message')
127
					.css('font-style', 'italic')
128
					.append('<br><br>Скрипт-кун благословил этот пост.')
129
				)
130
			}
131
		})
132
133
		$('.fuck-scoreboard-one').each(function(n, el){
134
			$(el).find('.fuck-scoreboard-one-score').html(score[n])
135
		})
136
137
	}, 1000)
138
})