Skip to content

Commit

Permalink
more fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
Notplayingallday383 committed Apr 24, 2024
1 parent b8732ad commit ea6a75d
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 18 deletions.
2 changes: 0 additions & 2 deletions components/modules/settings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import updateCache from "./cache";
import logDebug from "./debug";
import runUtils from "./utils"
export default async function loadSettings() {
await updateCache()
await logDebug()
window.addEventListener('DOMContentLoaded', () => runUtils);
const title = localStorage.getItem('websiteTitle');
const favicon = localStorage.getItem('websiteIcon');
const useRandomize = localStorage.getItem('useRandomizer')
Expand Down
2 changes: 1 addition & 1 deletion components/modules/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SetTransport } from "@mercuryworkshop/bare-mux"

export async function regSW() {
navigator.serviceWorker.register('/sw.js', {scope: "/sw/"}).then(await updateTransports)
navigator.serviceWorker.register('/dynsw.js', {scope: "/service/"})
navigator.serviceWorker.register('/dyn.sw.js', {scope: "/service/"})
}

export async function updateTransports() {
Expand Down
13 changes: 8 additions & 5 deletions components/modules/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default async function runUtils() {
// @ts-ignore
const Ultraviolet = window.parent.ultraviolet
import { XOR as xor } from "./xor"
export default async function runUtils(sessionCheck: string) {
// @ts-expect-error stfu
const iframe: HTMLIFrameElement = document.getElementById('apploader');
// @ts-expect-error stfu
Expand Down Expand Up @@ -28,10 +27,14 @@ export default async function runUtils() {
fpsItem.style.display = 'none';
if (iframe) {
const proxyOption = localStorage.getItem("proxyOption");
const urltoencode = sessionStorage.getItem(sessionCheck);
console.log(sessionCheck)
console.log(urltoencode)
if (proxyOption && proxyOption.toLowerCase() === "dynamic") {
iframe.src = `${window.location.origin}/service/route?url=https://github.com/z1g-project/sodium`;
iframe.src = `${window.location.origin}/service/route?url=${urltoencode}`;
} else {
const encodedURL = Ultraviolet.codec.xor.encode(sessionStorage.getItem('stealthurl'));
// @ts-expect-error stfu
const encodedURL = xor.encode(urltoencode.toString);
iframe.src = `${window.location.origin}/sw/${encodedURL}`;
}
iframe.onload = () => {
Expand Down
2 changes: 0 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Socket, Head } from "ws";
import NotFound from "./src/404"
import config from "dotenv";
import { dynamicPath } from "@nebula-services/dynamic";
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";

config.config();
const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -110,7 +109,6 @@ app.get('*', (req, res) => {
});
app.use("/libcurl/", express.static(libcurlPath));
app.use("/baremux/", express.static(baremuxPath));
app.use("/ultra/", express.static(uvPath));
app.use("/dyn/", express.static(dynamicPath));
const server = createServer();

Expand Down
10 changes: 6 additions & 4 deletions src/appframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export default function Appframe() {
cssthing.href = "/assets/css/frames.css"
cssthing.type = "stylesheet"
document.head.appendChild(cssthing)
runUtils()
// @ts-expect-error stfu
const loadingOverlay: HTMLDivElement = document.getElementById("loading-overlay");
loadingOverlay.style.display = "flex"
window.addEventListener('DOMContentLoaded', () => {
runUtils('appUrl')
// @ts-expect-error stfu
const loadingOverlay: HTMLDivElement = document.getElementById("loading-overlay");
loadingOverlay.style.display = "flex"
})
}
return (
<div>
Expand Down
8 changes: 4 additions & 4 deletions src/games.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ export default function Games() {
const proxyOption = localStorage.getItem("proxyOption");
if (proxyOption && proxyOption.toLowerCase() === "dynamic") {
const dynamicURL = `${window.location.origin}/service/${xor.encode(url)}`;
sessionStorage.setItem("appUrl", dynamicURL);
sessionStorage.setItem("encodedUrl", dynamicURL);
} else {
if (!checkUrl(url)) {
url = "https://www.google.com/search?q=" + url;
} else if (!(url.startsWith("https://") || url.startsWith("http://"))) {
url = "https://" + url;
}
sessionStorage.removeItem("appUrl");
sessionStorage.removeItem("encodedUrl");
const encodedUrl = `${window.location.origin}/sw/${xor.encode(url)}`;
sessionStorage.setItem("appUrl", encodedUrl);
sessionStorage.setItem("encodedUrl", encodedUrl);
}
location.href = "appframe";
location.href = "iframe";
};

function checkUrl(val = "") {
Expand Down
37 changes: 37 additions & 0 deletions src/iframe.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @ts-expect-error stfu
import Nav from "@components/nav.tsx"
// @ts-expect-error stfu
import Footer from "@components/footer"
// @ts-expect-error stfu
import runUtils from "@components/modules/utils"
export default function Iframe() {
if (window.location.href.includes('/appframe')) {
const cssthing = document.createElement("link")
cssthing.href = "/assets/css/frames.css"
cssthing.type = "stylesheet"
document.head.appendChild(cssthing)
window.addEventListener('DOMContentLoaded', () => {
runUtils('encodedUrl')
// @ts-expect-error stfu
const loadingOverlay: HTMLDivElement = document.getElementById("loading-overlay");
loadingOverlay.style.display = "flex"
})
}
return (
<div>
<Nav />
<div id="loading-overlay">
<div class="loading-content">
<img src="/assets/img/logo.svg" alt="Logo" width="125" height="125" />
<h1 class="loading-title">Sodium is loading your content!</h1>
<img src="/assets/img/loader.svg" alt="Loading Animation" width="50" height="50" />
<p class="loading-message">Please wait...</p>
</div>
</div>
<div class="show-iframe">
<iframe id="apploader"></iframe>
</div>
<Footer />
</div>
)
}
2 changes: 2 additions & 0 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Games from "./games"
import Home from "./main"
import Appframe from "./appframe";
import StealthLoader from "./stealth";
import Iframe from "./iframe";

export const router = (
<Route path="/">
Expand All @@ -24,6 +25,7 @@ export const router = (
<Route path="credits" show={<CreditsPage />} />
<Route path="about" show={<About />} />
<Route path="appframe" show={<Appframe />} />
<Route path="iframe" show={<Iframe />} />
<Route regex path=".*" show={<Notfound />} />
</Route>
).$
Expand Down
8 changes: 8 additions & 0 deletions src/stealth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
import Nav from "@components/nav.tsx"
// @ts-expect-error stfu
import Footer from "@components/footer"
// @ts-expect-error stfu
import runUtils from "@components/modules/utils"
export default function StealthLoader() {
if (window.location.href.includes('/stealth')) {
const cssthing = document.createElement("link")
cssthing.href = "/assets/css/frames.css"
cssthing.type = "stylesheet"
document.head.appendChild(cssthing)
window.addEventListener('DOMContentLoaded', () => {
runUtils('stealthurl')
// @ts-expect-error stfu
const loadingOverlay: HTMLDivElement = document.getElementById("loading-overlay");
loadingOverlay.style.display = "flex"
})
}
return (
<div>
Expand Down

0 comments on commit ea6a75d

Please sign in to comment.