FURSTREAM background toggle

Adds button to switch background to dark or light colored

当前为 2016-08-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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));
})