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