View difference between Paste ID: 6ZuZHCqM and SP94V8z5
SHOW: | | - or go back to the newest paste.
1
// ==UserScript==
2
// @name        LOR Classic
3
// @namespace   http://www.linux.org.ru/*
4
// @include     *linux.org.ru/*
5
// @require     http://code.jquery.com/jquery-1.8.1.min.js
6-
// @version     9
6+
// @version     10
7
// @author      Sadler
8
// @grant       none
9
// ==/UserScript==
10
11
//////////////////////////// НАСТРОЙКИ ////////////////////////
12
13
// без иконок "В избранное" и "Отслеживать"
14
noFavorites = true;
15
16
// решётки и заголовки у всех сообщений
17
gridLinks = true;
18
19
// перенести аватарки из футера
20
moveAvatar = true;
21
22
// старый вид навигации
23
oldNav = true;
24
25
// старый вид тегов
26
oldTags = true;
27
28
// теги после текста сообщения
29
tagsDown = true;
30
31
// обратная замена ёлочек
32
oldQuotation = true;
33
34
// показывать секунды в timestamp тем и комментариев
35
secondsInTimestamp = true;
36
// использовать UTC? Иначе используем локальное время
37-
useUTC = false;
37+
useUTC = true;
38
// сдвиг времени от UTC
39
UTCOffset = 4;
40
41
// отключить Gravatar
42
noGravatar = true;
43
44
//////////////////////////////////////////////////////////////
45
46
function dateFormat(comDate)
47
{	
48
	if (useUTC) 
49
	{
50
		//да, оно работает
51
		comDate.setHours(comDate.getHours()+UTCOffset);
52
		
53
54
		var dt = ''+(comDate.getUTCFullYear()%100);
55
		if (dt.length<2) dt = '0'+dt;
56
		dt = '.'+dt;
57
		dt = (comDate.getUTCMonth()+1)+dt;
58
		if (dt.length<5) dt = '0'+dt;
59
		dt = '.'+dt;
60
		dt = comDate.getUTCDate()+dt;
61
		if (dt.length<8) dt = '0'+dt;
62
63
		var dtstr = dt;
64
65
		var dt = ''+comDate.getUTCSeconds();
66
		if (dt.length<2) dt = '0'+dt;
67
		dt = ':'+dt;
68
		dt = (comDate.getUTCMinutes())+dt;
69
		if (dt.length<5) dt = '0'+dt;
70
		dt = ':'+dt;
71
		dt = comDate.getUTCHours()+dt;
72
		if (dt.length<8) dt = '0'+dt;
73
74
		dtstr += ' '+dt;
75
		return dtstr;
76
	}
77
	else 
78
	{
79
		var dt = ''+(comDate.getFullYear()%100);
80
		if (dt.length<2) dt = '0'+dt;
81
		dt = '.'+dt;
82
		dt = (comDate.getMonth()+1)+dt;
83
		if (dt.length<5) dt = '0'+dt;
84
		dt = '.'+dt;
85
		dt = comDate.getDate()+dt;
86
		if (dt.length<8) dt = '0'+dt;
87
88
		var dtstr = dt;
89
90
		var dt = ''+(comDate.getSeconds());
91
		if (dt.length<2) dt = '0'+dt;
92
		dt = ':'+dt;
93
		dt = (comDate.getMinutes())+dt;
94
		if (dt.length<5) dt = '0'+dt;
95
		dt = ':'+dt;
96
		dt = comDate.getHours()+dt;
97
		if (dt.length<8) dt = '0'+dt;
98
99
		dtstr += ' '+dt;
100
		return dtstr;
101
	}
102
}
103
104
105
if (window.location.hostname.indexOf('linux.org.ru') != -1) {
106
107
	$ = window.$;
108
	if (noFavorites) $('.fav-buttons').hide();
109
110
	isTango = false;
111
	if ($('.msg').first().css('border-radius') != '0px') isTango = true;
112
113
	if (moveAvatar || $('.userpic').length == 0) $('.sign').css('margin-left','0');
114
	$('.msg').css('padding','0');
115
	$('.msg-container').css('margin-left','5px');
116
	$('.msg-container').css('padding-bottom','7px');
117
118
	$('footer').css('border-top','0');
119
	$('footer').css('border-bottom','0');
120
	$('footer').css('padding-top','0');
121
	$('footer').css('padding-bottom','0');
122
	$('footer').css('margin-bottom','0');
123
124
	$('.msg h1').css('font-size','x-large');
125
	$('.msg h1').css('padding-left','10px');
126
	$('header').css('margin-bottom','0');
127
128
	$('.msg_body').css('margin-left','5px');
129
130
	$('.tags-section-info').css('border-top','0');
131
	$('.tags-section-info').css('border-bottom','0');
132
	$('.tags-section-info').css('padding-top','0');
133
	$('.tags-section-info').css('padding-bottom','0');
134
	$('.tags-section-info').css('padding-left','8px');
135
136
//	$('.fav-buttons a').css('font-size','100%');
137
138
	$('div[itemprop="articleBody"]').css('padding-bottom','0');
139
140
	$('.title').css('padding-left','5px');
141
142
	var navPath = "";
143
144
//////////////////////////// Отключение Gravatar ///////////////////////////////////////////
145
146
if (noGravatar) {	
147
	$('.userpic').each(function() {
148
		photo = $(this).children('.photo');
149
		src = photo.attr('src');
150
		if (src.indexOf('https://secure.gravatar.com/avatar/') != -1)
151
		photo.attr('src','');
152
		$(this).height(150);
153
	});
154
}
155
156
//////////////////////////// Изменение формата даты ////////////////////////////////////////
157
158
if (secondsInTimestamp) {
159
	$('time[itemprop="commentTime"]').each(function() {
160
		var comDate = new Date(Date.parse($(this).attr('datetime')));				
161
		$(this).text(dateFormat(comDate));
162
	});
163
164
	$('time[itemprop="dateCreated"]').each(function() {
165
		var comDate = new Date(Date.parse($(this).attr('datetime')));				
166
		$(this).text(dateFormat(comDate));
167
	});
168
169
	$('time[itemprop="false"]').each(function() {
170
		var comDate = new Date(Date.parse($(this).attr('datetime')));				
171
		$(this).text(dateFormat(comDate));
172
	});
173
174
175
}
176
177
178
//////////////////////////// Замена "ёлочек" ///////////////////////////////////////////////
179
180
if (oldQuotation) {
181
	$('.msg_body p').each(function(){
182
		msgtext = $(this).html();
183
		msgtext = msgtext.split('«').join('"');
184
		msgtext = msgtext.split('»').join('"');
185
		$(this).html(msgtext);
186
	});
187
}
188
189
////////////////////////////////////////////////////////////////////////////////////////////
190
191
	$('.msg').each(function() {
192
193
		message = $(this);
194
		title = message.children('.title');
195
		container = message.children('.msg-container');
196
		messagebody = container.children('.msg_body');
197
		msgfooter = messagebody.children('footer');
198
		reply = messagebody.children('.reply').children('ul');
199
		tags = message.children('header').children('.tags');
200
		navs = message.children('header').children('.msg-top-header').children('span[itemprop="articleSection"]');
201
202
203
//////////////////////////// FAV-ки в заголовок ///////////////////////////////////////////
204
/*	favText = container.children('.fav-buttons').html();
205
	if (favText !== undefined)
206
	{
207
		titleButtons = $('<div style="float: right;"></div>').addClass('fav-buttons');
208
		titleButtons.appendTo(title);
209
210
		$('#favs_button').appendTo(titleButtons);
211
		$('#favs_count').appendTo(titleButtons);
212
		$('<span> </span>').appendTo(titleButtons);
213
		$('#memories_button').appendTo(titleButtons);
214
		$('#memories_count').appendTo(titleButtons);
215
216
	}
217
*/
218
/////////////////////////// ИЩЕМ ССЫЛКИ И ПРЕВРАЩАЕМ ИХ В РЕШЁТКИ //////////////////////
219
220
if (gridLinks) {
221
		msg_link = "";
222
223
		reply.children('li').each(function() {
224
			msg_link = $(this).children('a').attr('href');
225
			if ($(this).children('a').text() == "Ссылка") $(this).hide();
226
		});
227
228
		oldTitle = title.html();
229
		title.html('[<a href="'+msg_link+'">#</a>] '+oldTitle);
230
}
231
else
232
{
233
		if (isTango && tags.length == 0) container.css('padding-top','7px');
234
}
235
236
///////////////////////// Старый вид тегов /////////////////////////////////////////////
237
238
		if ((tags !== undefined) && (tags != null) && oldTags)
239
		{
240
			tagsText = '<i class="icon-tag"></i> ';
241
242
			tagList = tags.children('.tag');
243
			if (tagList.length==0) tagsText = '';            
244
	
245
			tagList.each( function(index) {
246
				if (index>0) tagsText += ', ';
247
				tagName = $(this).html();
248
				tagsText += '<a class="tag" href="/tag/'+tagName+'" rel="tag">'+tagName+'</a>';
249
			});
250
          
251
if (tagsDown) {
252
			tags.appendTo(messagebody.children('div[itemprop="articleBody"]'));
253
			msgfooter.css('margin-top','7px');
254
255
}
256
257
			tags.css('font-size','13px');
258
			tags.html(tagsText);
259
		}
260
261
262
263
///////////////////////// ПЕРЕНОСИМ НАВИГАЦИЮ НАВЕРХ //////////////////////////////////
264
265
		if ((navs !== undefined) && (navs != null) && oldNav)
266
		{
267
			navPath2 = navs.html();
268
          
269
			if (navPath2 !== undefined && (navPath2 != null))
270
			{
271
				navPath = navPath2;
272
				navPath2 = navPath.split('<i class="icon-tag">')[0];
273
				if (navPath2.length > 0) navPath = navPath2;
274
			}
275
276
		}
277
278
//////////////////////// ИЩЕМ АВАТАРКУ НЕ НА МЕСТЕ ////////////////////////////////////
279
280
if (moveAvatar) {
281
		msgfooter.children('.userpic').each(function() {
282
			messagebody.children('div[itemprop="articleBody"]').css('padding-left','170px');
283
284
			messagebody.children('footer').css('margin-left','170px');
285
			messagebody.children('.reply').css('margin-left','170px');
286
287
			userpic = $(this);
288
289
			userpic.css('padding-top','5px');
290
			userpic.css('margin-right','10px');
291
292
			userpic.children('img').attr('width','150px');
293
			userpic.children('img').removeAttr('height');
294
			userpic.prependTo(messagebody);
295
		});
296
}
297
	});
298
299
//////////////////////// Восстанавливаем навигацию ////////////////////////////////////
300
301
302
	if (oldNav && $('#navPath').length == 0 && navPath.length > 0)
303
	{
304
		navPath = navPath.replace('Форум -','<a href="/forum/">Форум</a> -');
305
		$('#bd').prepend('<div class="nav"><div id="navPath">'+navPath+'</div></div>');
306
		$('.msg-top-header').hide();
307
	}
308
309
310
}