Missed this one during the lintfix

This commit is contained in:
Hamcha 2020-06-17 17:44:50 +02:00
parent 6b8b93bd81
commit 5ed479af20
Signed by: hamcha
GPG key ID: 41467804B19A3315
2 changed files with 7 additions and 28 deletions

View file

@ -16,8 +16,6 @@ export enum ColorFmt {
} }
function hsvToRgb({ h, s, v }: ColorHSV): ColorRGB { function hsvToRgb({ h, s, v }: ColorHSV): ColorRGB {
let r, g, b;
const i = Math.floor(h * 6); const i = Math.floor(h * 6);
const f = h * 6 - i; const f = h * 6 - i;
const p = v * (1 - s); const p = v * (1 - s);
@ -26,39 +24,20 @@ function hsvToRgb({ h, s, v }: ColorHSV): ColorRGB {
switch (i % 6) { switch (i % 6) {
case 0: case 0:
r = v; return { r: v, g: t, b: p };
g = t;
b = p;
break;
case 1: case 1:
r = q; return { r: q, g: v, b: p };
g = v;
b = p;
break;
case 2: case 2:
r = p; return { r: p, g: v, b: t };
g = v;
b = t;
break;
case 3: case 3:
r = p; return { r: p, g: q, b: v };
g = q;
b = v;
break;
case 4: case 4:
r = t; return { r: t, g: p, b: v };
g = p;
b = v;
break;
case 5: case 5:
r = v; return { r: v, g: p, b: q };
g = p;
b = q;
break;
default: default:
throw new Error("unreacheable"); throw new Error("unreacheable");
} }
return { r, g, b };
} }
function rgbToHsv({ r, g, b }: ColorRGB): ColorHSV { function rgbToHsv({ r, g, b }: ColorRGB): ColorHSV {

View file

@ -15,7 +15,7 @@ export default function userscript(root: HTMLElement, docname: string): void {
// Shitty way to detect if it's hex or not // Shitty way to detect if it's hex or not
// Basically, none of the css colors long 6 letters only use hex letters // Basically, none of the css colors long 6 letters only use hex letters
// THANK FUCKING GOD // THANK FUCKING GOD
if (bgcolor.length === 6 && Number.isNaN(parseInt(bgcolor, 16))) { if (bgcolor.length === 6 && !Number.isNaN(parseInt(bgcolor, 16))) {
bgcolor = `#${bgcolor}`; bgcolor = `#${bgcolor}`;
} }
td.setAttribute("bgcolor", darken(bgcolor, ColorFmt.HEX).slice(1)); td.setAttribute("bgcolor", darken(bgcolor, ColorFmt.HEX).slice(1));