Tinychat Optimizer

Adds "Optimize" button next to the tinychat.com logo while in a room. Clicking this button should remove unneeded components and Optimize the room to fit the browser window.

От 20.09.2017. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name        Tinychat Optimizer
// @namespace   http://tinychat.com/
// @version     1.5 BETA
// @author      elaw
// @description Adds "Optimize" button next to the tinychat.com logo while in a room. Clicking this button should remove unneeded components and Optimize the room to fit the browser window.
// @include     http://tinychat.com/*
// @include     http://tinychat.com/room/*
// @include     https://tinychat.com/room/*
// @include     https://tinychat.com/*
// @exclude     https://tinychat.com/home
// @exclude     https://tinychat.com/download
// @exclude     https://tinychat.com/settings
// @exclude     https://tinychat.com/login
// @exclude     https://tinychat.com/gifts
// @exclude     /^https?://tinychat.com/.*//
// @grant none
// ==/UserScript==

// Style adding
function addStyle(css)
{
    var style = document.createElement('style');
    style.innerHTML = css;
    style.type='text/css';
    document.getElementsByTagName('head')[0].appendChild(style);
}

// Element removal by id
function removeById(ids)
{
    ids.forEach(function(element) {
        var x = document.getElementById(element);
        if (x)
            x.parentNode.removeChild(x);
    });
}

// Resize to fit the window
function resizeTinyChat(size) { document.getElementById('chat').style.height = ($( document ).height()-size) + "px"; }
function resizeTinyChatMaximized()
{
    resizeTinyChat(0);
}
function resizeTinyChatSmallMode()
{
    resizeTinyChat(42);
}

// First cleanup function
function cleanTinyChat()
{
    // Modify css styles
    addStyle("#left_block { width: 100% ! important;}");
    addStyle("#wrapper { padding-bottom: 0px;}");
    addStyle("#room { padding: 0;}");
    addStyle("#header { margin: 0;}");
    addStyle("#tinychat { padding: 0px; min-height: 0;}");

    // Remove unncecessary elements
    removeById(["website", "room-gift-show", "footer", "tcad_container", "share-bar", "body_footer_ad"]);
    $('[href="https://tinychat.com/payment/upgrade_to_pro/step1"]').remove();
    $('[href="https://tinychat.com/payment/upgrade_to_pro/step2"]').remove();
    $('[href="https://tinychat.com/payment/promote_a_room/step1"]').remove();
    $('[href="https://tinychat.com/gifts"]').remove();
    $('[href="https://tinychat.com/download"]').remove();
    $('.btn-group').remove();
    $('#room_header').remove();

    // Disable Scrollbar
    document.documentElement.style.overflow = 'hidden';	 // Firefox, Chrome
    document.body.scroll = "no";	// IE Only

    // Resize the chat and make sure it resizes to window size
    resizeTinyChatSmallMode();
    window.addEventListener('resize', resizeTinyChatSmallMode, false);
}

// Main cleanup function
function maximizeTinyChat()
{
    // Remove unncecessary elements
    removeById(["header", "right_block", "room_header", "ad_banner", "chat-info", "goods", "category-bar", "left"]);

    // Resize to fit the window
    resizeTinyChatMaximized();
    window.removeEventListener("resize", resizeTinyChatSmallMode, false);
    window.addEventListener('resize', resizeTinyChatMaximized, false);
}

// move counter to Topbar
$( '#live-count' ).insertAfter( $( '#logo' ) );
var count_anyone = document.getElementById('live-count');
count_anyone.style.position = 'relative';
count_anyone.style.display = 'inline-block';
count_anyone.style.width = '100px';
count_anyone.style.height = '35px';
count_anyone.style.margin = '0px 20px 0px';		// oben/unten, links/rechts   -  oben, seiten, unten
count_anyone.style.padding = '8px 0px 0px';

// move info to Topbar
document.getElementById('room_info').classList.remove('name');
$( '#room_info' ).insertAfter( $( '#live-count' ) );
document.getElementById('room_info').id='room_info_anyone';
var info_anyone = document.getElementById('room_info_anyone');
if (info_anyone) {
	info_anyone.style.margin = '0px';
	info_anyone.style.verticalAlign = 'middle';
	info_anyone.style.display = 'inline-block';
	info_anyone.style.color = '#fff';

	$('h1 > small').remove();
	$('#room_info_anyone > h2').remove();
	$('#location').remove();
	$('#website').remove();
}

// Setup full window button
function addMaximizeButton()
{
    // Add the maximize button right after the logo
    var link = document.createElement('a');
    var div = document.getElementById('navigation');
    link.className = 'button white';
    link.addEventListener('click', maximizeTinyChat, false);
    link.innerHTML = 'Optimize';
    div.appendChild(link);
    $( ".button" ).css("border","0px");
}

// On load stuff here
function init()
{
    // Only work on rooms
    if (!document.getElementById('room'))
        return;

    // Move Info to Top Bar
    $( '#room_info' ).removeClass( 'name' )
        .insertAfter( '#logo' )
        .attr('id', 'room_info_anyone');

    addStyle('#room_info_anyone { margin: 0px; display: inline-block; color: #fff; vertical-align: middle; margin-top: 4px; margin-left: 25px; padding: 0;}');

    $('h1 > small').remove();
    $('#room_info_anyone > h2').remove();
    $('#location').remove();
    // Hide Popularity stuff if exists
    $('room-popularity-container').remove();

    // Execute the rest of the script
    cleanTinyChat();
    addMaximizeButton();
}

// Init Script Now after functions
init();