FURSTREAM background toggle

Adds button to switch background to dark or light colored

目前为 2016-08-06 提交的版本。查看 最新版本

// ==UserScript==
// @name        FURSTREAM background toggle
// @namespace   furstre.am
// @description Adds button to switch background to dark or light colored
// @include     https://furstre.am/stream/*
// @version     0
// @grant       none
// ==/UserScript==

function addGlobalStyle(css, id) {
	var style = $(document.createElement("style")).attr("type", "text/css").html(css);
	if(id) style.attr("id", id);
	$("head").append(style);
}

function toggleBackground() {
	var style = $("#dark-background");
	if(style.length) {
		do {
			style.remove();
			style = $("#dark-background");
		} while (style.length);

	}
	else {
		addGlobalStyle("body { color: #ddd !important; }", "dark-background");
		addGlobalStyle(".body .center { background-color: rgba(0, 0, 0, 0.8) !important; }", "dark-background");
		addGlobalStyle(".comunica{ color: #fff !important; }", "dark-background");
		addGlobalStyle(".comunica .comunica-top { background-color: #444 !important; }", "dark-background");
		addGlobalStyle(".comunica .comunica-top .button { color: rgba(255, 255, 255, 0.5) !important; }", "dark-background");
		addGlobalStyle(".comunica #comunica-chat-pane { background-color: #222 !important; color: #fff !important; }", "dark-background");
		addGlobalStyle(".comunica #comunica-chat-pane .msg .content { background-color: #444 !important; }", "dark-background");
		addGlobalStyle(".comunica .comunica-msg-input { background-color: #444 !important; color: #eee; }", "dark-background");
		addGlobalStyle(".comunica .comunica-smiles { opacity: 0.8 !important; }", "dark-background");
		addGlobalStyle(".comunica .comunica-menu { background-color: #444 !important; }", "dark-background");
	}
}

$(window).load(function(){
	$("#chat .comunica .comunica-top").append($(document.createElement("i")).addClass("fa fa-adjust fa-2x fa-fw button").click(toggleBackground));
})