iks: virtonomica форум

Добавление кнопки ответить как прочитанные на верх страницы. Так-же скрывает шапку темы и всю информацию ниже аватора под spoiler.

目前为 2015-06-25 提交的版本。查看 最新版本

// ==UserScript==
// @name        iks: virtonomica форум
// @namespace   virtonomica
// @description Добавление кнопки ответить как прочитанные на верх страницы. Так-же скрывает шапку темы и всю информацию ниже аватора под spoiler.
// @include     http://*virtonomic*.*/*/forum/forum_new/*/view*
// @include     http://*virtonomic*.*/*/forum/forum_new/*/topic/*/view*
// @version     1.25
// @grant       none
// ==/UserScript==

var run = function() {
    $("div#content > table").each(function() {
        if($(this).html().indexOf('Создать тему') + 1 ) {
            $(this).append('<tr><td colspan="2">'
                            + '<small>' + $('div#content > table.pagingContainer > tbody > tr > td > table.paging > tbody > tr > td').html().replace(/Страница:/g, '') + '</small>'
                            + $('div#content > table.pagingContainer > tbody > tr > td').html()
                            +'</td></tr>');
        }
    });
}

var topic = function() {
    var id, str;
    
    id = $('table.message_color2:first tr:nth-child(3) > td:nth-child(1)');
    str = $(id).html();
    if(str.length > 250) {
        $(id).html( '<div class="bbSpoiler" style="padding:0; border:none"><div class="bbSpoilerTitle">'
                +'<a href="#" onclick="return xbbSpoiler(this)" style="text-decoration:none"><span><strong><u>[+] Развернуть</u></strong>'
                +'<p style="color:#000; font-weight:normal">'
                + str.replace(/<[^>]+>/g,'').replace(/\[\+\] spoiler/g,'').replace(/\[-\] spoiler/g,' ').substring(0, 250)
                +'...</p></span><span style="display:none"><strong><u>[-] Свернуть</u></strong></span></a></div>'
                +'<div class="bbSpoilerText" style="display: none"><hr>'+ str + '</div></div>');
    }
    
    $('table.message_color2 tr:nth-child(2) > td:nth-child(1) > noindex').each(function() {
        $(this).find('script').remove();
        $(this).parent().css('width','170');
        str = '<table width="164" cellspacing="0" cellpadding="0" border="0" style="margin-left:4px;margin-bottom:5px;">' + $(this).find('table:first').html() + '</table>';
        $(this).find('table:first').remove();
        $(this).html( str +'<div class="bbSpoiler" style="padding:0; border:none"><div class="bbSpoilerTitle">'
                        +'<a href="#" onclick="return xbbSpoiler(this)" style="text-decoration:none"><span><strong><u>[+] Развернуть</u></strong>'
                        +'</span><span style="display:none"><strong><u>[-] Свернуть</u></strong></span></a></div>'
                        +'<div class="bbSpoilerText" style="padding:0; display: none;">' + $(this).html() + '</div></div>' );
    });
  
}

if(window.top == window) {
    if( window.location.href.indexOf('/topic') + 1 ) $( '<script/>', { text: '(' + topic.toString() + ')()' } ).appendTo('head');
    else $( '<script/>', { text: '(' + run.toString() + ')()' } ).appendTo('head');
}