Skip to content

Commit 87f7cbb

Browse files
juniorbutyeahjuniorbutyeah
andauthored
did canvas text whatever and changed UI, but thils will probably be overwritten (#315)
* did canvas text whatever and changed UI, but thils will probably be overwritten * fix biome stuff --------- Co-authored-by: juniorbutyeah <juniorbutyeah@github.com>
1 parent 3772564 commit 87f7cbb

11 files changed

Lines changed: 330 additions & 23 deletions

File tree

bun.lock

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { build } from "astro";
1616
import Fastify from "fastify";
1717
import INConfig from "./config";
1818
import { ASSET_FOLDERS, generateMaps, getClientScript, type ObfuscationMaps, ROUTES, transformCss, transformHtml, transformJs } from "./src/lib/obfuscate";
19+
import { getTextCanvasClientScript, transformTextInHtml } from "./src/lib/text-canvas";
1920

2021
let obfuscationMaps: ObfuscationMaps | null = null;
2122

@@ -325,6 +326,7 @@ self.addEventListener("fetch", (event) => {
325326
if (obfuscationMaps) {
326327
const maps = obfuscationMaps;
327328
const routeScript = getClientScript(maps);
329+
const textScript = getTextCanvasClientScript(maps.textKey);
328330

329331
const transformMiddleware = (_req: IncomingMessage, res: ServerResponse, next: () => void) => {
330332
const originalWriteHead = res.writeHead.bind(res);
@@ -436,7 +438,8 @@ self.addEventListener("fetch", (event) => {
436438

437439
if (contentType === "html") {
438440
content = transformHtml(content, maps);
439-
content = content.replace(/<\/head>/i, `${routeScript}</head>`);
441+
content = transformTextInHtml(content, maps.textKey);
442+
content = content.replace(/<\/head>/i, `${routeScript}${textScript}</head>`);
440443
} else if (contentType === "css") {
441444
content = transformCss(content, maps);
442445
} else if (contentType === "js") {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"lucide-astro": "^0.556.0",
3636
"lucide-react": "^0.561.0",
3737
"mime": "^4.0.7",
38+
"node-html-parser": "^7.1.0",
3839
"react": "19.2.3",
3940
"react-dom": "19.2.3",
4041
"sharp": "^0.34.5",

src/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
1+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
22

33
@tailwind base;
44
@tailwind components;

src/layouts/Main.astro

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const navLinks = [
1919
<Layout>
2020
<nav
2121
id="default-nav"
22-
class="fixed top-0 left-0 right-0 z-[99999] flex items-center justify-between px-5 py-3 bg-background/90 backdrop-blur-md border-b border-white/10"
22+
class="fixed top-4 left-4 right-4 z-[99999] flex items-center justify-between px-6 py-3 bg-background/90 backdrop-blur-md border border-white/10 rounded-2xl shadow-lg"
2323
>
2424
<a
2525
href="/"
26-
class="text-3xl font-bold text-text hover:text-accent transition-colors tracking-tighter"
26+
class="inline-block text-5xl font-black leading-none text-text hover:-translate-y-0.5 tracking-normal [-webkit-text-stroke:1px_currentColor]"
2727
>
2828
IN
2929
</a>
@@ -33,9 +33,9 @@ const navLinks = [
3333
navLinks.map((link) => (
3434
<a
3535
href={link.href}
36-
class="inline-flex items-center gap-2 rounded px-3 py-1.5 text-sm text-text-secondary hover:text-text hover:bg-white/10 transition-all"
36+
class="inline-flex items-center gap-2 rounded-md px-4 py-2 text-base text-text-secondary hover:-translate-y-0.5"
3737
>
38-
<link.Icon class="w-4 h-4" strokeWidth={1.5} />
38+
<link.Icon class="w-5 h-5" strokeWidth={1.5} />
3939
<span>{link.text}</span>
4040
</a>
4141
))
@@ -47,30 +47,30 @@ const navLinks = [
4747
class="p-2 text-text-secondary hover:text-text transition-colors"
4848
aria-label="Toggle menu"
4949
>
50-
<Menu id="menu-icon" class="w-6 h-6 transition-transform duration-200" strokeWidth={1.5} />
51-
<X id="close-icon" class="w-6 h-6 hidden transition-transform duration-200" strokeWidth={1.5} />
50+
<Menu id="menu-icon" class="w-7 h-7 transition-transform duration-200" strokeWidth={1.5} />
51+
<X id="close-icon" class="w-7 h-7 hidden transition-transform duration-200" strokeWidth={1.5} />
5252
</button>
5353
</nav>
5454

5555
<div
5656
id="nav-menu"
57-
class="fixed top-14 right-4 z-[99998] min-w-[180px] bg-background/95 backdrop-blur-sm border border-white/10 p-2 shadow-2xl origin-top-right transition-all duration-200 ease-out opacity-0 scale-95 pointer-events-none"
57+
class="fixed top-24 right-4 z-[99998] min-w-[200px] bg-background/95 backdrop-blur-sm border border-white/10 rounded-2xl p-2 shadow-2xl origin-top-right transition-all duration-200 ease-out opacity-0 scale-95 pointer-events-none"
5858
>
5959
{
6060
navLinks.map((link, i) => (
6161
<a
6262
href={link.href}
63-
class="menu-item flex items-center gap-3 px-3 py-2.5 text-text-secondary hover:text-text hover:bg-white/10 transition-all duration-150"
63+
class="menu-item flex items-center gap-3 px-4 py-3 text-text-secondary hover:text-text hover:bg-white/10 transition-all duration-150"
6464
style={`transition-delay: ${i * 30}ms;`}
6565
>
66-
<link.Icon class="w-4 h-4" strokeWidth={1.5} />
67-
<span class="text-sm">{link.text}</span>
66+
<link.Icon class="w-5 h-5" strokeWidth={1.5} />
67+
<span class="text-base">{link.text}</span>
6868
</a>
6969
))
7070
}
7171
</div>
7272

73-
<main class="flex flex-col min-h-screen pt-14">
73+
<main class="flex flex-col min-h-screen pt-24">
7474
<slot />
7575
</main>
7676
</Layout>

src/lib/obfuscate.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface ObfuscationMaps {
1919
assets: Record<string, string>;
2020
reverseAssets: Record<string, string>;
2121
version: string;
22+
textKey: number;
2223
}
2324

2425
function genRandom(length: number, used: Set<string>): string {
@@ -75,7 +76,8 @@ export function generateMaps(): ObfuscationMaps {
7576
}
7677

7778
const version = crypto.randomBytes(8).toString("hex");
78-
return { routes, reverseRoutes, code, assets, reverseAssets, version };
79+
const textKey = (crypto.randomBytes(1)[0] | 1) & 0xff;
80+
return { routes, reverseRoutes, code, assets, reverseAssets, version, textKey };
7981
}
8082

8183
export function transformHtml(html: string, maps: ObfuscationMaps): string {

0 commit comments

Comments
 (0)