Advertisement
Guest User

Linux.org.ru Classic v7

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