diff --git a/serverside/name-color.ts b/serverside/name-color.ts index 321b53c..a94fe1a 100644 --- a/serverside/name-color.ts +++ b/serverside/name-color.ts @@ -43,7 +43,8 @@ async function get_name_color(name: string): Promise { for (const p of dom.querySelectorAll("p")) { const text = p.textContent; if (text.startsWith("name-color: ")) { - const color = text.split("name-color: ")[1] + const line = text.split("\n", 1)[0]; + const color = line.split("name-color: ")[1] .slice(0, MAX_COLOR_LEN) .replaceAll(/[;{}"']/g, ""); if (is_valid_color(color)) { @@ -77,15 +78,15 @@ function cssify({ requester }: { requester?: string }): string { let vars = `:root {\n`; if (requester && colors[requester]) { - vars += `--name-color: var(--name-color-${requester});\n`; + vars += `--name-color: var(--name-color-${requester.toLowerCase()});\n`; } let classes = ""; for (const name of Object.keys(colors).sort()) { const { color } = colors[name]; if (!color) continue; - vars += `--name-color-${name}: ${color};\n`; + vars += `--name-color-${name.toLowerCase()}: ${color};\n`; classes += - `a[href$='/${name}']{color: var(--name-color-${name}) !important;}\n`; + `a[href$='/${name}' i]{color: var(--name-color-${name.toLowerCase()}) !important;}\n`; } vars += "}\n\n"; return preamble + vars + classes;