TorViet Shoutbox Enhancer

A small script to simplify the shoutbox

ของเมื่อวันที่ 11-05-2015 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         TorViet Shoutbox Enhancer
// @namespace    http://torviet.com/userdetails.php?id=1662
// @version      0.4
// @license      http://www.wtfpl.net/txt/copying/
// @icon         http://torviet.com/pic/salad.png
// @description  A small script to simplify the shoutbox
// @author       Salad
// @match        http://torviet.com/qa.php*
// @grant        none
// ==/UserScript==

$(function(){
    // Remove unneeded stuffs
    $('#boxHead').remove();
    $('.marquee').remove();
    $('#sltTheme').remove();
    $('#clock').remove();

    // Alter existing element CSS
    $('.all-wrapper').css({
        'background-image': 'none',
        'margin': 'auto',
        'height': $(window).height()
    });
    $('.input-section').parent().css('padding', '0px');
    $('.navigation_page').css('width', 'auto');
    $('#boxQuestion').css('height', $(window).height() - getRemainingHeight() - 20);
    $('#emo-section').css('height', $(window).height() - getRemainingHeight() - 22);

    // Alter existing element attributes
    $('#emogroup option:contains("Voz")').prop('selected', true);

    // Add elements
    var myScript = document.createElement('script');
    myScript.type = 'text/javascript';
    myScript.innerHTML = 'function toggleEmoSlt() {' +
        '$(".emo-group-title-wrapper").slideToggle();' +
        '}';
    $('.input-section-a').append(myScript);
    $('.input-section-a').append('<input type="button" value="Toggle" onclick="toggleEmoSlt()" />');

    // Functions
    toggleEmoSlt();
    $('#emogroup').change();
    $('#idQuestion').focus();
    setTimeout(function(){
        addEmoticons();

        $('a.btuEmotion').click(function(){
            var x = $('#idQuestion').attr('value');
            $('#idQuestion').attr('value', x + $(this).attr('alt'));
            $('#idQuestion').focus();
        });
    }, 200);

    function getRemainingHeight() {
        return $('.input-section').parent().height() + $('.navigation_page').height();
    }

    function addEmoticons() {
        var emo = '<div style="height:43px;width:43px;float:left;display:inline-block;margin:1px;"><a style="margin:0px 0px 0px 0px;" class="btuEmotion" alt="[em707]"><img style="max-width: 43px; max-height: 43px" src="/pic/smilies/707.gif" alt=""></a></div>';
        $('.emo-group-detail').append(emo);
        for (i = 200; i < 234; i++) {
            emo = '<div style="height:43px;width:43px;float:left;display:inline-block;margin:1px;"><a style="margin:0px 0px 0px 0px;" class="btuEmotion" alt="[em' + i + ']"><img style="max-width: 43px; max-height: 43px" src="/pic/smilies/' + i + '.gif" alt=""></a></div>';
            $('.emo-group-detail').append(emo);
        }
    }
});