User:Sarah777/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Sarah777/monobook.css. |
importScript('User:Outriggr/metadata.js');
importScript('User:AzaToth/twinkle.js');
// Custom color changing signature
addOnloadHook(dynamicSignature);
function dynamicSignature() {
signature = "[[User talk:Sarah777|<font color='"+someColor()+"'>'''Sarah777'''</font>]]";
theForms = document.getElementsByTagName('form');
for (f = 0; f < theForms.length; f++) {
theForm = theForms[f];
if (theForm.name != 'editform') continue;
theForm.setAttribute("onSubmit", "this.wpTextbox1.value = this.wpTextbox1.value+\"\\n\"; this.wpTextbox1.value = this.wpTextbox1.value.replace(/ ~{4}([^~])/g, ' '+signature+' ~~'+'~~'+'~'+\"$1\");");
break;
}
}
function someColor() {
var now = new Date();
seconds = now.getTime() / 1000;
index = (seconds % 86400) - 43200;
if (index < 0) index = index * -1;
start_color = [ 18 , 141 , 15 ];
end_color = [ 251 , 40 , 25 ];
new_color = '#'+
decToHex(Math.round(gradientPoint(start_color[0], end_color[0], 43200, index)))+
decToHex(Math.round(gradientPoint(start_color[1], end_color[1], 43200, index)))+
decToHex(Math.round(gradientPoint(start_color[2], end_color[2], 43200, index)));
return (new_color);
}
function gradientPoint (low, high, steps, step) {
xsteps = steps + 1;
xdistance = high - low;
step_value = xdistance/xsteps;
value = low;
value = value + (step * step_value);
return value;
}
function decToHex(dec) {
var hexChars = "0123456789ABCDEF";
var low = dec % 16;
var high = (dec - low)/16;
hex = "" + hexChars.charAt(high) + hexChars.charAt(low);
return hex;
}