NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Random Chameleon // @description Auto color formatting for the chatbox. // @namespace too much grease // @include http://aimgames.forummotion.com/* // @version 1.1 // @grant none // ==/UserScript== 'use strict';function r(){function d(a){a=a||{};a.b&&!n&&(n=a.b);var b,c,e;if(null!=a.count){b=a.count;c=[];for(a.count=null;b>c.length;)c.push(d(a));a.count=b;a.b&&(n=a.b);return c}a:{b=a.i;if("number"===typeof parseInt(b)&&(c=parseInt(b),360>c&&0<c)){b=[c,c];break a}if("string"===typeof b&&q[b]&&(b=q[b],b.a)){b=b.a;break a}b=[0,360]}b=p(b);0>b&&(b=360+b);c=a;if("random"===c.g)c=p([0,100]);else if("monochrome"===c.i)c=0;else{var f=t(b).m;e=f[0];f=f[1];switch(c.g){case "bright":e=55;break;case "dark":e= f-10;break;case "light":f=55}c=p([e,f])}a:{for(var k=t(b).j,h=0;h<k.length-1;h++){e=k[h][0];var f=k[h][1],x=k[h+1][0],g=k[h+1][1];if(c>=e&&c<=x){k=(g-f)/(x-e);e=k*c+(f-k*e);break a}}e=0}f=100;switch(a.g){case "dark":f=e+20;break;case "light":e=(f+e)/2;break;case "random":e=0,f=100}e=p([e,f]);return m([b,c,e],a)}function m(a,b){switch(b.format){case "hsvArray":return a;case "hslArray":return y(a);case "hsl":var c=y(a);return"hsl("+c[0]+", "+c[1]+"%, "+c[2]+"%)";case "rgbArray":return w(a);case "rgb":return"rgb("+ w(a).join(", ")+")";default:return u(a)}}function t(a){334<=a&&360>=a&&(a-=360);for(var b in q){var c=q[b];if(c.a&&a>=c.a[0]&&a<=c.a[1])return q[b]}return"Color not found"}function p(a){if(null==n)return Math.floor(a[0]+Math.random()*(a[1]+1-a[0]));var b=a[1]||1;a=a[0]||0;n=(9301*n+49297)%233280;return Math.floor(a+n/233280*(b-a))}function u(a){function b(a){a=a.toString(16);return 1==a.length?"0"+a:a}a=w(a);return"#"+b(a[0])+b(a[1])+b(a[2])}function g(a,b,c){q[a]={a:b,j:c,m:[c[0][0],c[c.length-1][0]], s:[c[c.length-1][1],c[0][1]]}}function w(a){var b=a[0];0===b&&(b=1);360===b&&(b=359);var b=b/360,c=a[1]/100;a=a[2]/100;var e=Math.floor(6*b),f=6*b-e,b=a*(1-c),d=a*(1-f*c),c=a*(1-(1-f)*c),h=f=256,g=256;switch(e){case 0:f=a;h=c;g=b;break;case 1:f=d;h=a;g=b;break;case 2:f=b;h=a;g=c;break;case 3:f=b;h=d;g=a;break;case 4:f=c;h=b;g=a;break;case 5:f=a,h=b,g=d}return[Math.floor(255*f),Math.floor(255*h),Math.floor(255*g)]}function y(a){var b=a[1]/100,c=a[2]/100,e=(2-b)*c;return[a[0],Math.round(b*c/(1>e?e: 2-e)*1E4)/100,e/2*100]}var n=null,q={};g("monochrome",null,[[0,0],[100,0]]);g("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]);g("orange",[19,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]);g("yellow",[47,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]);g("green",[63,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]);g("blue",[179,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44], [90,39],[100,35]]);g("purple",[258,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]);g("pink",[283,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]);return d}if("function"===typeof define&&define.o)define([],r);else if("object"===typeof exports){var v=r();"object"===typeof module&&module&&module.h&&(exports=module.h=v);exports.l=v}else this.l=r(); function z(){var d=new_col,m="",m=new Date;m.setTime(m.getTime()+864E5);m="; expires="+m.toGMTString();document.cookie="CB_color="+d+m+"; path=/"}function A(){var d=new_col,d=d.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(d,t,p,u){return t+t+p+p+u+u});return(d=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(d))?{r:parseInt(d[1],16),f:parseInt(d[2],16),c:parseInt(d[3],16)}:null} if(null!==document.getElementById("frame_chatbox")||null!==document.getElementById("message"))1>=window.location.pathname.length?(new_col="#ffffff",document.getElementById("frame_chatbox").contentWindow.document.getElementById("message").addEventListener("keyup",function(d){13==(d.keyCode?d.keyCode:d.which)&&(new_col=randomColor(),z(),document.getElementById("frame_chatbox").contentWindow.document.getElementById("scolor").value=new_col,document.getElementById("frame_chatbox").contentWindow.document.getElementById("divcolor-preview").style.cssText= "background-color: rgb("+A().r+", "+A().f+", "+A().c+");",document.getElementById("frame_chatbox").contentWindow.document.getElementById("message").style.color=new_col)},!1)):(new_col="#ffffff",document.getElementById("message").addEventListener("keyup",function(d){13==(d.keyCode?d.keyCode:d.which)&&(new_col=randomColor(),z(),document.getElementById("scolor").value=new_col,document.getElementById("divcolor-preview").style.cssText="background-color: rgb("+A().r+", "+A().f+", "+A().c+");",document.getElementById("message").style.color= new_col)},!1));