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 {
let r, g, b;
const i = Math.floor(h * 6);
const f = h * 6 - i;
const p = v * (1 - s);
@ -26,39 +24,20 @@ function hsvToRgb({ h, s, v }: ColorHSV): ColorRGB {
switch (i % 6) {
case 0:
r = v;
g = t;
b = p;
break;
return { r: v, g: t, b: p };
case 1:
r = q;
g = v;
b = p;
break;
return { r: q, g: v, b: p };
case 2:
r = p;
g = v;
b = t;
break;
return { r: p, g: v, b: t };
case 3:
r = p;
g = q;
b = v;
break;
return { r: p, g: q, b: v };
case 4:
r = t;
g = p;
b = v;
break;
return { r: t, g: p, b: v };
case 5:
r = v;
g = p;
b = q;
break;
return { r: v, g: p, b: q };
default:
throw new Error("unreacheable");
}
return { r, g, b };
}
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
// Basically, none of the css colors long 6 letters only use hex letters
// THANK FUCKING GOD
if (bgcolor.length === 6 && Number.isNaN(parseInt(bgcolor, 16))) {
if (bgcolor.length === 6 && !Number.isNaN(parseInt(bgcolor, 16))) {
bgcolor = `#${bgcolor}`;
}
td.setAttribute("bgcolor", darken(bgcolor, ColorFmt.HEX).slice(1));