mihir
VIP Member
Ok so how do I begin with this, is there a tutorial or something which I can follow.
I checked out kobaj's code.
Like in the code below how do I know the class names and other stuff?
Thanks
Feedback: I like the black one but the text boxes feel weird otherwise everything else looks fine
I checked out kobaj's code.
Like in the code below how do I know the class names and other stuff?
Thanks
Feedback: I like the black one but the text boxes feel weird otherwise everything else looks fine
Code:
// ==UserScript==
// @name Change Color
// @namespace com.kobaj
// @description Change the Color of CoFo
// @include http://www.computerforum.com*
// ==/UserScript==
var numberofthemes = 4;
//TODO
//get and set link colors
//get and set post box/comment box.
//dun touch this
//********************************//
var options = [];
for (var i = 0; i < numberofthemes; i++)
{
options = options.concat(document.createElement('option'));
}
//overview
//********************************//
//name of your theme
options[0].innerHTML = "Dark";
options[1].innerHTML = "White";
options[2].innerHTML = "default";
options[3].innerHTML = "Invert";
//********************************//
//specials
var smallfontText = ["#ffffff", "#000000", "", "#ffffff"];
var timeText = ["#ffffff", "#000000", "", "#ffffff"];
var tborderColor = ["#000000", "#000000", "", "#ffffff"];
//********************************//
//quickreply
var panelSurroundColor = ["#555555", "#ffffff", "", "#000000"];
var panelColor = ["#555555", "#ffffff", "", "#111111"];
//********************************//
//tcat
var tcatColor = ["#222222", "#ffffff", "", "#202020"];
var tcatText = ["#ffffff", "#000000", "", "#ffffff"];
//********************************//
//.alt2 .alt2active #headerbar
var alt2Color = ["#444444", "#ffffff", "", "#0E0E0E"];
var alt2Text = ["#ffffff", "#000000", "", "#ffffff"];
//********************************//
//alt1 alt1active
var alt1Color = ["#666666", "#ffffff", "", "#000000"];
var alt1Text = ["#ffffff", "#000000", "", "#ffffff"];
//********************************//
//page body
var pageColor = ["#888888", "#ffffff", "", "#333333"];
var pageText = ["#ffffff", "#000000", "", "#ffffff"];
//********************************//
//thead bands of color
var prefColor = ["#000000", "#ffffff", "", "#E0A22E"];
var prefText = ["#ffffff", "#000000", "", "#ffffff"];
//put it all together!
//********************************//
var thead = document.getElementsByClassName('thead');
var tfeet = document.getElementsByClassName('tfoot');
var vbmenu_control = document.getElementsByClassName('vbmenu_control');
var tcat = document.getElementsByClassName('tcat');
var alt2 = document.getElementsByClassName('alt2');
var alt2active = document.getElementsByClassName('alt2Active');
var headerbar = document.getElementById('headerbar');
var alt1 = document.getElementsByClassName('alt1');
var alt1active = document.getElementsByClassName('alt1Active');
var page = document.getElementsByClassName('page');
var panelSurround = document.getElementsByClassName('panelsurround');
var panel = document.getElementsByClassName('panel');
var smallfont = document.getElementsByClassName('smallfont');
var time = document.getElementsByClassName('time');
var tborder = document.getElementsByClassName('tborder');
//links
//functions
//********************************//
var index = 0;
function ChangeBackgroundColors(elementsT, inputColor)
{
var i=0;
for (i=0;i<elementsT.length;i++)
{
elementsT[i].style.setProperty("background", inputColor, "important");
}
return;
}
function ChangeTextColors(elementsT, inputColor)
{
for(var i = 0; i < elementsT.length; i++)
{
elementsT[i].style.setProperty("color", inputColor, "important");
}
return;
}
function SetAllBackgrounds()
{
ChangeBackgroundColors(thead, prefColor[index]);
ChangeBackgroundColors(tfeet, prefColor[index]);
ChangeBackgroundColors(vbmenu_control, prefColor[index]);
ChangeBackgroundColors(tcat, tcatColor[index]);
ChangeBackgroundColors(alt2, alt2Color[index]);
ChangeBackgroundColors(alt2active, alt2Color[index]);
//ChangeBackgroundColors(headerbar, alt2Color[index]);
headerbar.style.setProperty("background", alt2Color[index], "important");
ChangeBackgroundColors(alt1, alt1Color[index]);
ChangeBackgroundColors(alt1active, alt1Color[index]);
ChangeBackgroundColors(page, pageColor[index]);
//ChangeBackgroundColors(document.body, pageColor[index]);
document.body.style.setProperty("background", pageColor[index], "important");
ChangeBackgroundColors(panelSurround, panelSurroundColor[index]);
ChangeBackgroundColors(panel, panelColor[index]);
ChangeBackgroundColors(tborder, tborderColor[index]);
}
function SetAllText()
{
ChangeTextColors(thead, prefText[index]);
ChangeTextColors(tfeet, prefText[index]);
ChangeTextColors(vbmenu_control, prefText[index]);
ChangeTextColors(tcat, tcatText[index]);
ChangeTextColors(alt2, alt2Text[index]);
ChangeTextColors(alt2active, alt2Text[index]);
headerbar.style.setProperty("color", alt2Text[index], "important");
ChangeTextColors(alt1, alt1Text[index]);
ChangeTextColors(alt1active, alt1Text[index]);
ChangeTextColors(page, pageColor[index]);
document.body.style.setProperty("color", pageText[index], "important");
ChangeTextColors(smallfont, smallfontText[index]);
ChangeTextColors(time, timeText[index]);
//and just about the worst way to handle link color. Oh well.
var links = document.getElementsByTagName( 'a' );
for ( var i = 0; i < links.length; i++ )
{
links[i].style.color = pageText[index];
}
}
function SetTThings()
{
SetAllBackgrounds();
SetAllText();
}
GetState();
SetTThings();
//********************************//
//DropDownMenu
var selectionBox = document.createElement('select');
function OnChange()
{
var myIndex = selectionBox.selectedIndex;
//var selValue = selectionBox.options[myIndex].value;
index = myIndex;
SetTThings();
SaveState();
}
selectionBox.name = "ColorChooser";
selectionBox.addEventListener("change", function(e){OnChange()},false);
for(var i = 0; i<options.length;i++)
{
selectionBox.appendChild(options[i]);
}
document.body.appendChild(selectionBox);
//********************************//
//save state
function SaveState()
{
GM_setValue("cofoColorChoice2",index);
}
function GetState()
{
index = GM_getValue("cofoColorChoice2");
if(index == null)
{
index = 0;
}
options[index].selected = "selected";
}