fork init
This commit is contained in:
parent
b4f5aba93b
commit
2e6b63ea33
11 changed files with 8 additions and 2651 deletions
41
.forgejo/scripts/convert/index.mjs
Normal file
41
.forgejo/scripts/convert/index.mjs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { readFile, writeFile } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import { format } from "prettier";
|
||||
|
||||
console.time("Done");
|
||||
|
||||
console.log("Reading avatarsdatabase.css...");
|
||||
const avis = (await readFile(join("../../", "avatarsdatabase.css"), "utf8"))
|
||||
.replace(/\r/g, "")
|
||||
.split("\n");
|
||||
|
||||
const imageMatcher = /url\((?:'|")([^'"]+)(?:'|")\)/;
|
||||
const avatarMatcher = /^\/\* Custom avatar for ([0-9]+) \*\/$/;
|
||||
const badgeMatcher = /^\/\* Custom badge for (.*?) \*\/$/;
|
||||
|
||||
const avatars = {};
|
||||
for (let i = 0; i < avis.length; i++) {
|
||||
const l = avis[i];
|
||||
const id = l.match(avatarMatcher)?.[1];
|
||||
if (id) avatars[id] = avis[i + 2].match(imageMatcher)[1];
|
||||
}
|
||||
|
||||
const badges = {};
|
||||
for (let i = 0; i < avis.length; i++) {
|
||||
const l = avis[i];
|
||||
const bid = l.match(badgeMatcher)?.[1];
|
||||
if (bid) badges[bid] = avis[i + 10].match(imageMatcher)[1];
|
||||
}
|
||||
|
||||
await writeFile(
|
||||
join("../../", "source", "data.json"),
|
||||
format(
|
||||
JSON.stringify({
|
||||
avatars,
|
||||
badges,
|
||||
}),
|
||||
{
|
||||
parser: "json",
|
||||
}
|
||||
)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue