Change style background

Change style background for website http://valvrareteam.com/

当前为 2016-09-27 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Change style background
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Change style background for website http://valvrareteam.com/
// @author       Nguyen Huu Tien
// @include      http://valvrareteam.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    jQuery(document).ready(function($){
        var $fbComment = $('.fb-comments');
        
        var handleStyles = {
            black: function() {
                $('.article, .single_post').css({backgroundColor: 'black', color: 'white'});
                $fbComment.find('> span').css({backgroundColor: 'black', color: 'white'});
            },
            white: function() {
                $('.article, .single_post').css({backgroundColor: 'white', color: 'black'});
                $fbComment.find('> span').css({backgroundColor: 'black', color: 'white'});
            },
        };
        var $body = $('body');

        var $controllerContainer = $('<div title="Skin" class="controller-container"><div style="background-color: black;" data-handle-style-name="black" class="styles style-black"></div><div style="background-color: white;" data-handle-style-name="white" class="styles style-white"></div></div>');
        $controllerContainer.css({
            position: 'fixed',
            width: 30,
            right: 5,
            top: 50,
            border: 'black solid 1px',
            zIndex: 1000,
            backgroundColor: '#19B753',
            padding: 2
        });
        var $handleStylesElement = $controllerContainer.find('.styles');
        $handleStylesElement.css({
            width: '100%',
            height: 20,
            cursor: 'pointer'
        });

        $handleStylesElement.on('click', function(){
            var handle = handleStyles[$(this).data('handle-style-name')];
            if(typeof handle === 'function') {
                handle();
            }
        });

        $controllerContainer.appendTo($body);

        handleStyles.white();
        var interval = setInterval(function() {
            var $span = $fbComment.find('> span');
             if($span.length) {
                $span.css({backgroundColor: 'black', color: 'white'});
                 clearInterval(interval);
             }
        }, 100);
    });
})();