Jump to content

User:Sarah777/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
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;
}