Distraction-free Tinychat

Eliminates everything from a Tinychat page except the chatroom

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Distraction-free Tinychat
// @namespace   tinychat.com
// @description Eliminates everything from a Tinychat page except the chatroom
// @include     http://tinychat.com/*
// @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/.*//
// @version     0.3
// ==/UserScript==

function cleanPage() {
	//Remove ads:
	document.getElementById("right_block").remove();
	//Expand chat to fill space previously occupied by ads:
	document.getElementById("left_block").style.width = "100%";
	//Remove Tinychat navigation bar:
	document.getElementById("header").remove();
	//Remove social sharing bar:
	document.getElementById("share-bar").remove();
	//Remove room info:
	document.getElementById("room_header").remove();
	//Remove Tinychat copyright/TOS message:
	document.getElementById("footer").remove();
	//Remove blank space from bottom of page:
	document.getElementById("wrapper").style.paddingBottom = "0px";
	//NOTE: you have to resize the window to "kick" the chat window into filling the screen
	//Otherwise this padding will remain
}

GM_registerMenuCommand("Clean Page", cleanPage);

//Thanks to http://stackoverflow.com/a/18120786/1874170 for the following code:
Element.prototype.remove = function() {
	this.parentElement.removeChild(this);
}
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
	for(var i = this.length - 1; i >= 0; i--) {
		if(this[i] && this[i].parentElement) {
			this[i].parentElement.removeChild(this[i]);
		}
	}
}