Skip to content

Commit

Permalink
V6.0.0 - Add basic logic for assets, use tsconfig aliases, fix name o…
Browse files Browse the repository at this point in the history
…f type
  • Loading branch information
IncognitoTGT committed Jun 24, 2024
1 parent 7761c91 commit f39db70
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare global {
};
}
}
import "../global.css";
import "@/global.css";
import { ViewTransitions } from "astro:transitions";
---
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Main.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { AppWindow, Gamepad2, LayoutGrid, Settings2, Wrench } from "lucide-astro";
import Obfuscated from "../components/Obfuscated.astro";
import Obfuscated from "@/components/Obfuscated.astro";
import Layout from "./Layout.astro";
const navLinks = [
{ href: "/ap", text: "Apps", Icon: LayoutGrid },
Expand Down
26 changes: 26 additions & 0 deletions src/lib/asset-script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Asset } from "@/lib/asset";
document.addEventListener("astro:page-load", () => {
const buttons = document.querySelectorAll(
"[data-asset]",
) as NodeListOf<HTMLButtonElement>;
for (const button of buttons) {
button.addEventListener("click", () => {
const asset: Asset = JSON.parse(button.dataset.asset!);
if (asset.say) alert(asset.say);
if (asset.link) {
sessionStorage.setItem("goUrl", asset.link);
return location.replace("/tb");
}
if (asset.links) {
const selection = prompt(
`Select a link to go to: ${asset.links.map(({ name }, idx) => `\n${name}: ${idx + 1}`).join("")}`,
);
if (!selection) return;
const link = asset.links[Number.parseInt(selection) - 1];
if (!link) return alert("Invalid selection");
sessionStorage.setItem("goUrl", link.url);
return location.replace("/tb");
}
});
}
});
4 changes: 2 additions & 2 deletions src/lib/asset.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const ASSET_URL =
"https://raw.githubusercontent.com/UseInterstellar/Interstellar-Assets/main";

export type App = {
export type Asset = {
name: string;
image: string;
link?: string;
links?: { name: string; url: string };
links?: { name: string; url: string }[];
say?: string;
partial?: boolean | string;
error?: boolean | string;
Expand Down
6 changes: 2 additions & 4 deletions src/lib/cloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ function getRandomURL() {
return randomURLS[randRange(0, randomURLS.length)];
}

function randRange(min: number, max: number) {
return Math.floor(Math.random() * (max - min) + min);
}

const randRange = (min: number, max: number) =>
Math.floor(Math.random() * (max - min) + min);
if (!localStorage.getItem("ab")) localStorage.setItem("ab", "true");

if (
Expand Down
19 changes: 12 additions & 7 deletions src/pages/ap.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
import { Image } from "astro:assets";
import { LayoutGrid } from "lucide-astro";
import Obfuscated from "../components/Obfuscated.astro";
import Layout from "../layouts/Main.astro";
import { ASSET_URL, type App } from "../lib/asset";
const apps: App[] = await (await fetch(`${ASSET_URL}/json/apps.json`)).json();
import Obfuscated from "@/components/Obfuscated.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/asset";
const apps: Asset[] = await (await fetch(`${ASSET_URL}/json/apps.json`)).json();
---

<Layout>
Expand All @@ -16,14 +16,19 @@ const apps: App[] = await (await fetch(`${ASSET_URL}/json/apps.json`)).json();
<div class="flex flex-wrap justify-center gap-4 flex-row mt-30">
{
apps.map((app) => (
<a href={app.link}>
<button data-asset={JSON.stringify(app)}>
<div class="flex flex-col items-center p-4 bg-secondary size-48 rounded-md space-y-4 hover:bg-interactive duration-150">
<Image loading="eager" src={ASSET_URL + app.image} alt={app.name} height={145} width={145} class="size-24 rounded-md" />
<Obfuscated class="text-center font-semibold text-xl text-wrap" text={app.name} />
<Obfuscated
class="text-center font-semibold text-xl text-wrap"
class:list={{ "text-red-600": app.error, "text-yellow-400": app.partial }}
text={app.name}
/>
</div>
</a>
</button>
))
}
</div>
</div>
</Layout>
<script src="@/lib/asset-script.ts"></script>
21 changes: 13 additions & 8 deletions src/pages/ga.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
import { Image } from "astro:assets";
import { Gamepad2 } from "lucide-astro";
import Obfuscated from "../components/Obfuscated.astro";
import Layout from "../layouts/Main.astro";
import { ASSET_URL } from "../lib/asset";
const games = await (await fetch(`${ASSET_URL}/json/games.json`)).json();
import Obfuscated from "@/components/Obfuscated.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/asset";
const games: Asset[] = await (await fetch(`${ASSET_URL}/json/games.json`)).json();
---

<Layout>
Expand All @@ -15,15 +15,20 @@ const games = await (await fetch(`${ASSET_URL}/json/games.json`)).json();
</div>
<div class="flex flex-wrap justify-center gap-4 flex-row mt-30">
{
games.map((game: any) => (
<a href={game.link}>
games.map((game) => (
<button data-asset={JSON.stringify(game)}>
<div class="flex flex-col items-center p-4 bg-secondary size-48 rounded-md space-y-4 hover:bg-interactive duration-150">
<Image loading="eager" src={ASSET_URL + game.image} alt={game.name} height={145} width={145} class="size-24 rounded-md" />
<Obfuscated class="text-center font-semibold text-xl text-wrap" text={game.name} />
<Obfuscated
class="text-center font-semibold text-xl text-wrap"
class:list={{ "text-red-600": game.error, "text-yellow-400": game.partial }}
text={game.name}
/>
</div>
</a>
</button>
))
}
</div>
</div>
</Layout>
<script src="@/lib/asset-script.ts"></script>
61 changes: 40 additions & 21 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,38 +1,57 @@
---
import Layout from "../layouts/Main.astro";
import Layout from "@/layouts/Main.astro";
const splashText = [
"Over 8 Million Users since 2023",
"Fastest growing proxy server",
"Made by xBubbo",
"Check out discord.gg/interstellar :)",
"Thanks for using the site",
"Follow us on Tiktok (@useinterstellar)",
"Subscribe to us on YouTube (@unblocking)",
"Subscribe to my Youtube (@xbubbo)",
"Check out the settings page",
"Check out our Patreon (https://www.patreon.com/gointerstellar)",
];
---

<script src="../lib/cloak.ts"></script>
<script src="@/lib/cloak.ts"></script>
<Layout>
<h3 class="flex text-8xl font-black uppercase place-content-center mt-40">Interstellar</h3>
<div class="flex place-content-center mt-4">
<input
class="h-16 rounded-md w-1/2 py-3 px-4 placeholder-text-secondary leading-tight focus:outline-none bg-interactive border-border"
placeholder="Search"
onkeydown="inputDown"
id="search"
/>
<div class="flex h-full flex-col">
<h3 class="flex text-8xl font-black uppercase place-content-center mt-40 hover:scale-105 hover:-translate-y-1 duration-150">Interstellar</h3>
<div id="form" class="flex mt-4 flex-col items-center justify-center gap-4">
<span class="text-accent">{splashText[Math.floor(Math.random() * splashText.length)]}</span>
<input
class="h-16 rounded-md w-1/2 py-3 px-4 placeholder-text-secondary leading-tight focus:outline-none bg-interactive border-border"
placeholder="Search"
id="search"
/>
</div>
</div>
</Layout>
<script>
const searchUrl = localStorage.getItem("engine") || "https://www.google.com/search?q=";
const input = document.getElementById("search") as HTMLInputElement;
const input = document.getElementById("search") as HTMLInputElement | null;
function isUrl(val = "") {
if (/^http(s?):\/\//.test(val) || (val.includes(".") && !val.includes(" "))) {
return true;
}
return false;
}
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
let url = input.value;
if (!isUrl(url)) {
url = searchUrl + url;
} else if (!(url.startsWith("https://") || url.startsWith("http://"))) {
url = `https://${url}`;
}
// TODO: change this logic
window.location.href = `/jquery/${window.__uv$config.encodeUrl(url)}`;
document.addEventListener("astro:page-load", () => {
if (input) {
input.focus();
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
let url = input.value;
if (!isUrl(url)) {
url = searchUrl + url;
} else if (!(url.startsWith("https://") || url.startsWith("http://"))) {
url = `https://${url}`;
}
sessionStorage.setItem("goUrl", url);
location.replace("/tb");
}
});
}
});
</script>
7 changes: 7 additions & 0 deletions src/pages/st.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
import Layout from "@/layouts/Main.astro";
---

<Layout>
<main>settings</main>
</Layout>
11 changes: 8 additions & 3 deletions src/pages/tb.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
---
import Layout from "../layouts/Layout.astro";
export const prerender = true;
import Layout from "@/layouts/Layout.astro";
---

<Layout>
<div>tabs</div>
<a href="/">home</a>
<iframe id="frame__1" class="w-full h-screen"></iframe>
</Layout>
<script>
const frame = document.getElementById("frame__1") as HTMLIFrameElement;
frame.src =
window.__uv$config.prefix + window.__uv$config.encodeUrl(sessionStorage.getItem("goUrl") || localStorage.getItem("engine") || "https://www.google.com");
</script>
15 changes: 8 additions & 7 deletions src/pages/to.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
import { Image } from "astro:assets";
import { Wrench } from "lucide-astro";
import Obfuscated from "../components/Obfuscated.astro";
import Layout from "../layouts/Main.astro";
import { ASSET_URL } from "../lib/asset";
const tools = await (await fetch(`${ASSET_URL}/json/tools.json`)).json();
import Obfuscated from "@/components/Obfuscated.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/asset";
const tools: Asset[] = await (await fetch(`${ASSET_URL}/json/tools.json`)).json();
---

<Layout>
Expand All @@ -15,15 +15,16 @@ const tools = await (await fetch(`${ASSET_URL}/json/tools.json`)).json();
</div>
<div class="flex flex-wrap justify-center gap-4 flex-row mt-30">
{
tools.map((tool: any) => (
<a href={tool.link}>
tools.map((tool) => (
<button>
<div class="flex flex-col items-center p-4 bg-secondary size-48 rounded-md space-y-4 hover:bg-interactive duration-150">
<Image loading="eager" src={ASSET_URL + tool.image} alt={tool.name} height={145} width={145} class="size-24 rounded-md" />
<Obfuscated class="text-center font-semibold text-xl text-wrap" text={tool.name} />
</div>
</a>
</button>
))
}
</div>
</div>
</Layout>
<script src="@/lib/asset-script.ts"></script>
6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
},
"exclude": ["node_modules", "dist", "public/assets/bundled/**"]
}

0 comments on commit f39db70

Please sign in to comment.