···
4
4
* SPDX-License-Identifier: GPL-3.0-or-later
5
5
*/
6
6
7
7
+
import { execSync } from "child_process";
7
8
import { build, type BuildOptions, context } from "esbuild";
8
9
10
10
+
const version = execSync("git describe --always", { encoding: "utf8" })
11
11
+
.replace(/^v/, "")
12
12
+
.replace(/-(\d+)-g/, "-git.$1+")
13
13
+
.trim();
9
14
const watch = process.argv.includes("--watch") || process.argv.includes("-w");
10
15
11
16
function userscriptBanner(meta: Record<string, string | string[]>) {
···
29
34
30
35
const banner = userscriptBanner({
31
36
name: "UserSky",
37
37
+
version,
38
38
+
description: "A client modification for Bluesky",
39
39
+
author: "rini (@rini.tngl.sh)",
40
40
+
namespace: "https://usersky.wisp.place",
32
41
match: [
33
42
"https://bsky.app/*",
34
43
// "https://deer.social/*", FIXME older build with less module splitting. sad for snitching modules
···
4
4
* SPDX-License-Identifier: GPL-3.0-or-later
5
5
*/
6
6
7
7
-
import { mkdir, rm, writeFile } from "node:fs/promises";
7
7
+
import { writeFile } from "node:fs/promises";
8
8
import * as pathlib from "node:path";
9
9
10
10
console.log("Fetching https://bsky.app");
11
11
12
12
const html = await fetch("https://bsky.app").then(r => r.text());
13
13
-
14
14
-
await rm("dist/bsky", { recursive: true, force: true });
15
15
-
await mkdir("dist/bsky", { recursive: true });
13
13
+
const sources = html.matchAll(/https:\/\/web-cdn\.bsky\.app\/[^"']*\.js/g).map(([url]) => url).toArray();
16
14
17
17
-
await Promise.all(html.matchAll(/https:\/\/web-cdn\.bsky\.app\/[^"']*\.js/g).map(async ([url]) => {
15
15
+
await Promise.all(sources.map(async url => {
18
16
console.log(`Fetching ${url}`);
19
17
20
18
const filename = pathlib.basename(url);
21
19
const script = await fetch(url).then(r => r.text());
22
20
23
23
-
await writeFile(pathlib.join("dist/bsky", filename), script);
21
21
+
await writeFile(pathlib.join("bluesky", filename), script);
24
22
}));
23
23
+
24
24
+
await writeFile(pathlib.join("bluesky", "sources.json"), JSON.stringify({
25
25
+
fetchedAt: new Date(),
26
26
+
sources,
27
27
+
}, null, 4));