Guest User

Linux.org.ru Classic v9

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