Distraction-free Tinychat

Eliminates everything from a Tinychat page except the chatroom

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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]);
		}
	}
}