Background Color figuccio

Change the background color

当前为 2022-06-14 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Background Color figuccio
// @namespace    https://greasyfork.org/users/237458
// @match          *://*/*
// @author         figuccio
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// @version      0.4
// @noframes
// @license        MIT
// @description Change the background color
// ==/UserScript==

//Set Cookie
var date = new Date();
date.setDate(date.getDate() + 10*1000).toLocaleString();

var exp_date = new Date();
exp_date.setDate(exp_date.getDate() - 10).toLocaleString();

var cookie = document.cookie.toString();
var color_str = /bgcolor=[a-z#0-9]*/i;
var check = color_str.exec(cookie);
if(check){
var current_bgcolor = check.toString().slice(8);
}
if(current_bgcolor){
document.body.style.background = current_bgcolor;
}

//Clear cookie
function remove(){
var current_bgcolor_str = "bgcolor="+current_bgcolor;
document.cookie = current_bgcolor_str+';expires='+exp_date;
}

//CSS Here
var css1 = "a#color_button{text-align:center;padding-left:1px;width:97px;color:green;background:#d8d8d8;display:block;font-size:16px;border:2px red solid;}";
var css2 = "div#main_div{cursor:pointer;}div#colors{color: blue;cursor:pointer;padding-left:2px;padding-top:4px;padding-bottom:4px;}span.colors{text-align:center;display:block;border:1px solid black};";
var css = css1 + css2;
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = "text/css";
style.innerHTML = css;
head.insertBefore(style,head.childNodes[1]);



//Choices of Colors
var inner_code1 = '<div id="main_div"><a id="color_button">COLORI</a></div><br>';

//Add colors here  //'<span class="colors" id="color">COLOR</span><br>'+ //
var inner_code2 = ['<div id="colors">'+
'<span class="colors" id="red" style="background:red;width:60px;">RED</span><br>'+
'<span class="colors" id="lightred" style="background:#fa6671;width: 60px;">LIGHT RED</span><br>'+ //#fa6671
'<span class="colors" id="purple" style="background:purple;width: 60px;">PURPLE</span><br>'+
'<span class="colors" id="lightpurple" style="background:#cd81d9;width: 60px;">LIGHT PURPLE</span><br>'+ //#cd81d9
'<span class="colors" id="green" style="background:green;width: 60px;">GREEN</span><br>'+
'<span class="colors" id="lightgreen" style="background:#7aff70;width: 60px;">LIGHT GREEN</span><br>'+ //#7aff70
'<span class="colors" id="orange" style="background:orange;width: 60px;">ORANGE</span><br>'+
'<span class="colors" id="lightorange" style="background:#ff8e42;width: 60px;">LIGHT ORANGE</span><br>'+ //#ff8e42
'<span class="colors" id="lightyellow" style="background:#fff370;width: 60px;">LIGHT YELLOW</span><br>'+ //#fff370
'<span class="colors" id="lightblue" style="background:#b8feff;width: 60px;">LIGHT BLUE</span><br>'+ //#b8feff
'<span class="colors" id="blue" style="background:#3131cd;width: 60px;">BLUE</span><br>'+ //#3131cd
'<span class="colors" id="pinkdeep" style="background:#FF1493;width: 60px;">DEEP PINK</span><br>'+ // #FF1493
'<span class="colors" id="redorange" style="background:#FF4500;width: 60px;">RED ORANGE</span><br>'+ //#FF4500
'<span class="colors" id="grey" style="background:#666666;width: 60px;">GREY</span><br>'+//#666666
'<span class="colors" id="lightgrey" style="background:#dedede;width: 60px;">LIGHT GREY</span><br>'+ //#dedede

//End add colors
'<span class="colors" id="reset" style="background:#526169;width: 60px;">RESET</span><br>'+ //#526169
'</div>'].join();

var inner_code = inner_code1 + inner_code2;
var div = function(){
var a = document.getElementsByTagName('body')[0];
var b = document.createElement('div');
b.style.position = 'absolute';
b.style.top = '50px';
b.style.left = '0px';
b.innerHTML = inner_code;
a.appendChild(b);
}
div();


//Hide or Show
if(document.cookie.toString().match(/block/)){
$("#colors").show();
}
else if(document.cookie.toString().match(/none/)){
$("#colors").hide();
}
else{
$(function(){$("#colors").hide();})
}


var disp;
$("#main_div").click(function() {
    	$("#colors").slideToggle(function get_disp(){
    disp = document.getElementById('colors').style.display;
    document.cookie = disp +';expires='+date;
});

});



//Color executing functions
//FOR WHITE
var reset = document.getElementById('reset');
reset.onclick = function(){
remove();
window.location = "/";
}

//FOR RED
var red = document.getElementById('red');
red.onclick = function(){
remove();
document.body.style.background = "red";
var color = "bgcolor=red";
document.cookie= color+';expires='+date;
}

//FOR LIGHT RED
var lightred = document.getElementById('lightred');
lightred.onclick = function(){
remove();
document.body.style.background = "#fa6671";
var color = "bgcolor=#fa6671";
document.cookie= color+';expires='+date;
}

//FOR PURPLE
var purple = document.getElementById('purple');
purple.onclick = function(){
remove();
document.body.style.background = "purple";
var color = "bgcolor=purple";
document.cookie= color+';expires='+date;
}

//FOR LIGHT PURPLE
var lightpurple = document.getElementById('lightpurple');
lightpurple.onclick = function(){
remove();
document.body.style.background = "#cd81d9";
var color = "bgcolor=#cd81d9";
document.cookie= color+';expires='+date;
}


//FOR GREEN
var green = document.getElementById('green');
green.onclick = function(){
remove();
document.body.style.background = "green";
var color = "bgcolor=green";
document.cookie= color+';expires='+date;
}

//FOR LIGHT GREEN
var lightgreen = document.getElementById('lightgreen');
lightgreen.onclick = function(){
remove();
document.body.style.background = "#7aff70";
var color = "bgcolor=#7aff70";
document.cookie= color+';expires='+date;
}

//FOR ORANGE
var orange = document.getElementById('orange');
orange.onclick = function(){
remove();
document.body.style.background = "orange";
var color = "bgcolor=orange";
document.cookie= color+';expires='+date;
}

//FOR LIGHT ORANGE
var lightorange = document.getElementById('lightorange');
lightorange.onclick = function(){
remove();
document.body.style.background = "#ff8e42";
var color = "bgcolor=#ff8e42";
document.cookie= color+';expires='+date;
}

//FOR YELLOW
var lightyellow = document.getElementById('lightyellow');
lightyellow.onclick = function(){
remove();
document.body.style.background = "#fff370";
var color = "bgcolor=#fff370";
document.cookie= color+';expires='+date;
}

//FOR LIGHT BLUE
var darkblue = document.getElementById('lightblue');
darkblue.onclick = function(){
remove();
document.body.style.background = "#b8feff";
var color = "bgcolor=#b8feff";
document.cookie= color+';expires='+date;
}

//FOR BLUE
var blue = document.getElementById('blue');
blue.onclick = function(){
remove();
document.body.style.background = "#3131cd";
var color = "bgcolor=#3131cd";
document.cookie= color+';expires='+date;
}

//FOR DEEP PINK
var pinkdeep = document.getElementById('pinkdeep');
pinkdeep.onclick = function(){
remove();
document.body.style.background = "#FF1493";
var color = "bgcolor=#FF1493";
document.cookie= color+';expires='+date;
}

//FOR RED ORANGE
var redorange = document.getElementById('redorange');
redorange.onclick = function(){
remove();
document.body.style.background = "#FF4500";
var color = "bgcolor=#FF4500";
document.cookie= color+';expires='+date;
}


//FOR GREY
var black = document.getElementById('grey');
black.onclick = function(){
remove();
document.body.style.background = "#666666";
var color = "bgcolor=#666666";
document.cookie= color+';expires='+date;
}

//FOR LIGHT GREY
var lightblack = document.getElementById('lightgrey');
lightblack.onclick = function(){
remove();
document.body.style.background = "#dedede";
var color = "bgcolor=#dedede";
document.cookie= color+';expires='+date;
}