Advertisement
Guest User

Linux.org.ru Classic v11

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