Torn - Less Cluttered Forums

try to take over the world!

当前为 2018-06-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Torn - Less Cluttered Forums
// @author       Xiphias[187717]
// @namespace    https://greasyfork.org/users/3898
// @version      1.0
// @include      *torn.com/forums.php*
// @description  try to take over the world!
// @grant        none
// ==/UserScript==

$( document ).ajaxComplete(function( event, xhr, settings ) {
    if ( settings.url.search(/forums.php.*/) === 0) {
        var forum_header = $('.forums-committee');

        var header_rating = forum_header.find('.rating');
        var header_rating_width = header_rating.outerWidth();

        var header_thread_name = forum_header.find('.thread-name');

        var header_thread_name_width = header_thread_name.width();
        header_thread_name.width(header_thread_name_width + header_rating_width);


        // Remove ratings on main forum page
        header_rating.remove();
        $('.threads-list').find('.rating').remove();

        if (settings.data.search('&f=19&') < 0) { // If not bugs forum
            $('.threads-list').find('> li').each(function() {
                var li = $(this);
                var thread_name = li.find('.thread-name');
                var thread_pages = li.find('.thread-pages');
                var new_max_width;
                if (thread_pages.length > 0) { // exists
                    thread_pages.removeClass('left');
                    thread_pages.addClass('right');
                    thread_pages.css('margin-right', '10px');
                    new_max_width = 400 - thread_pages.outerWidth() + 'px';
                } else {
                    new_max_width = '400px';
                }
                thread_name.css('max-width', new_max_width);

            });
        }

        if (settings.data.search('&f=19&') >= 0) { // Is bugs forum
            $('.threads-list').find('> li').each(function() {
                var li = $(this);
                var thread_name = li.find('.thread-name');
                var thread_pages = li.find('.thread-pages');
                var new_max_width;
                if (thread_pages.length > 0) { // exists
                    thread_pages.removeClass('left');
                    thread_pages.addClass('right');
                    thread_pages.css('margin-right', '8px');
                    new_max_width = 300 - thread_pages.outerWidth() + 'px';
                } else {
                    new_max_width = '300px';
                }
                thread_name.css('max-width', new_max_width);

            });
        }



        // remove rating values
        $('.like.forum-button').find('.value').remove();
        $('.dislike.forum-button').find('.value').remove();

        // remove rating dashboard on main forum
        var dashboard_rating = $('.dashboard.rating');
        var karma_rating_text = dashboard_rating.find('.title-black').html();
        if(typeof karma_rating_text !== 'undefined') {
            karma_rating_text = karma_rating_text.replace(/Karma Rating/g, 'Post Count');
            dashboard_rating.find('.title-black').html(karma_rating_text);
            dashboard_rating.find('.rating').remove();
        }

        // change feed
        var feed = $('#feed-threads');
        var fm_list = feed.find('.panel.fm-list');

        fm_list.find('.like-icon').remove();
        fm_list.find('.dislike-icon').remove();

        var feedbacks = fm_list.find('.post-wrap');
        feedbacks.each(function() {
            var feedback_text = $(this).html();

            feedback_text = feedback_text.replace(/(dis)?liked your post/g, 'reacted to your post');
            $(this).html(feedback_text);
        });

        // Popular threads
        var popular_threads = $('#pop-threads');
        if(typeof popular_threads !== 'undefined') {
            popular_threads.find('.like-wrap').remove();
            popular_threads.find('.dislike-wrap').remove();
        }

        var poster_wrap_left = $('.poster-wrap.left');
        poster_wrap_left.find('.karma').remove();

    }
});