take first line, downcase names, insensitive matching
This commit is contained in:
parent
8a5ff92104
commit
08f5f5ad12
1 changed files with 5 additions and 4 deletions
|
@ -43,7 +43,8 @@ async function get_name_color(name: string): Promise<string | undefined> {
|
||||||
for (const p of dom.querySelectorAll("p")) {
|
for (const p of dom.querySelectorAll("p")) {
|
||||||
const text = p.textContent;
|
const text = p.textContent;
|
||||||
if (text.startsWith("name-color: ")) {
|
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)
|
.slice(0, MAX_COLOR_LEN)
|
||||||
.replaceAll(/[;{}"']/g, "");
|
.replaceAll(/[;{}"']/g, "");
|
||||||
if (is_valid_color(color)) {
|
if (is_valid_color(color)) {
|
||||||
|
@ -77,15 +78,15 @@ function cssify({ requester }: { requester?: string }): string {
|
||||||
|
|
||||||
let vars = `:root {\n`;
|
let vars = `:root {\n`;
|
||||||
if (requester && colors[requester]) {
|
if (requester && colors[requester]) {
|
||||||
vars += `--name-color: var(--name-color-${requester});\n`;
|
vars += `--name-color: var(--name-color-${requester.toLowerCase()});\n`;
|
||||||
}
|
}
|
||||||
let classes = "";
|
let classes = "";
|
||||||
for (const name of Object.keys(colors).sort()) {
|
for (const name of Object.keys(colors).sort()) {
|
||||||
const { color } = colors[name];
|
const { color } = colors[name];
|
||||||
if (!color) continue;
|
if (!color) continue;
|
||||||
vars += `--name-color-${name}: ${color};\n`;
|
vars += `--name-color-${name.toLowerCase()}: ${color};\n`;
|
||||||
classes +=
|
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";
|
vars += "}\n\n";
|
||||||
return preamble + vars + classes;
|
return preamble + vars + classes;
|
||||||
|
|
Loading…
Reference in a new issue