From 180688bdee30cbdc959fe731f18b016867338c8b Mon Sep 17 00:00:00 2001 From: Thedogecraft Date: Sat, 26 Oct 2024 16:10:34 -0700 Subject: [PATCH] Updated CloakJS version --- index.js | 16 ++++---- package.json | 1 + pnpm-lock.yaml | 20 ++++++++++ public/js/cloak.js | 78 --------------------------------------- public/uv/index.js | 5 +-- public/views/index.ejs | 1 + public/views/layout.ejs | 2 +- public/views/settings.ejs | 10 ++--- 8 files changed, 38 insertions(+), 95 deletions(-) delete mode 100644 public/js/cloak.js diff --git a/index.js b/index.js index 8a107a3..f6bc05d 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ import express from "express"; import { createServer } from "node:http"; import chalk from "chalk"; -import httpProxy from 'http-proxy'; +import proxy from "express-http-proxy"; import { uvPath } from "@titaniumnetwork-dev/ultraviolet"; import { epoxyPath } from "@mercuryworkshop/epoxy-transport"; import { baremuxPath } from "@mercuryworkshop/bare-mux/node"; @@ -11,7 +11,7 @@ import expressLayouts from "express-ejs-layouts"; import { fileURLToPath } from "url"; import packageJson from "./package.json" with { type: "json" }; import compression from "compression"; -const cdnProxy = httpProxy.createProxyServer(); + const app = express(); const __dirname = dirname(fileURLToPath(import.meta.url)); const publicPath = join(__dirname, "public"); @@ -32,12 +32,12 @@ app.disable('x-powered-by'); app.get("/", (req, res) => { res.render("index"); }); -app.use('/cdn', (req, res) => { - cdnProxy.web(req, res, { - target: 'https://glcdn.githack.com/Thedogecraft/assets/-/raw/main/public/', - changeOrigin: true - }); -}); +app.use( + '/cdn', + proxy(`https://glcdn.githack.com`, { + proxyReqPathResolver: (req) => `/Thedogecraft/assets/-/raw/main/public/${req.url}`, + }) +); app.get("/science", (req, res) => { res.render("games"); }); diff --git a/package.json b/package.json index 2747cdc..8c59966 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "ejs": "^3.1.10", "express": "^4.18.2", "express-ejs-layouts": "^2.5.1", + "express-http-proxy": "^2.1.1", "http-proxy": "^1.18.1", "wisp-server-node": "^1.1.0", "ws": "^8.17.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 96b353e..05b1ea5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: express-ejs-layouts: specifier: ^2.5.1 version: 2.5.1 + express-http-proxy: + specifier: ^2.1.1 + version: 2.1.1 http-proxy: specifier: ^1.18.1 version: 1.18.1 @@ -267,6 +270,9 @@ packages: resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} engines: {node: '>= 0.4'} + es6-promise@4.2.8: + resolution: {integrity: sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==} + escape-html@1.0.3: resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} @@ -280,6 +286,10 @@ packages: express-ejs-layouts@2.5.1: resolution: {integrity: sha512-IXROv9n3xKga7FowT06n1Qn927JR8ZWDn5Dc9CJQoiiaaDqbhW5PDmWShzbpAa2wjWT1vJqaIM1S6vJwwX11gA==} + express-http-proxy@2.1.1: + resolution: {integrity: sha512-4aRQRqDQU7qNPV5av0/hLcyc0guB9UP71nCYrQEYml7YphTo8tmWf3nDZWdTJMMjFikyz9xKXaURor7Chygdwg==} + engines: {node: '>=6.0.0'} + express@4.19.2: resolution: {integrity: sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==} engines: {node: '>= 0.10.0'} @@ -809,6 +819,8 @@ snapshots: es-errors@1.3.0: {} + es6-promise@4.2.8: {} + escape-html@1.0.3: {} etag@1.8.1: {} @@ -817,6 +829,14 @@ snapshots: express-ejs-layouts@2.5.1: {} + express-http-proxy@2.1.1: + dependencies: + debug: 3.2.7(supports-color@5.5.0) + es6-promise: 4.2.8 + raw-body: 2.5.2 + transitivePeerDependencies: + - supports-color + express@4.19.2: dependencies: accepts: 1.3.8 diff --git a/public/js/cloak.js b/public/js/cloak.js deleted file mode 100644 index e7f2f1d..0000000 --- a/public/js/cloak.js +++ /dev/null @@ -1,78 +0,0 @@ -const logo = "\x1b[91m[Parcoil Cloak]\x1b[0m"; - -const cloak = { - getFavicon() { - const icons = document.querySelectorAll('link[rel="icon"]'); - return icons.length > 0 ? icons[0].href : null; - }, - setFavicon(url) { - const icons = document.querySelectorAll('link[rel="icon"]'); - icons.forEach((icon) => (icon.href = url)); - }, - getTitle() { - return document.title; - }, - setTitle(newTitle) { - document.title = newTitle; - }, - setCloak(newTitle, url) { - document.title = newTitle; - const icons = document.querySelectorAll('link[rel="icon"]'); - icons.forEach((icon) => (icon.href = url)); - localStorage.setItem("cloakTitle", newTitle); - localStorage.setItem("cloakFavicon", url); - }, - init() { - let cloakTitle = localStorage.getItem("cloakTitle"); - let cloakFavicon = localStorage.getItem("cloakFavicon"); - - if (!cloakTitle || !cloakFavicon) { - console.log(logo, "Initializing cloak settings..."); - const newTitle = this.getTitle(); - const newFavicon = this.getFavicon(); - if (!cloakTitle) { - localStorage.setItem("cloakTitle", newTitle); - } - if (!cloakFavicon && newFavicon) { - localStorage.setItem("cloakFavicon", newFavicon); - } - cloakTitle = localStorage.getItem("cloakTitle"); - cloakFavicon = localStorage.getItem("cloakFavicon"); - } - - // console.log(logo, `Title: ${cloakTitle} Favicon URL: ${cloakFavicon}`); - }, -}; - -document.addEventListener("DOMContentLoaded", () => { - let savedTitle = localStorage.getItem("cloakTitle"); - let savedFavicon = localStorage.getItem("cloakFavicon"); - - cloak.setFavicon(savedFavicon); - cloak.setTitle(savedTitle); - - const cloakSelect = document.getElementById("cloakSelect"); - - if (cloakSelect) { - cloakSelect.addEventListener("change", () => { - const selectedCloakName = cloakSelect.value; - const selectedCloak = cloaks.find( - (cloak) => cloak.name === selectedCloakName - ); - - if (selectedCloak) { - cloak.setCloak(selectedCloak.title, selectedCloak.icon); - console.log(`Selected cloak title: ${selectedCloak.title}`); - } else { - console.error( - `Cloak '${selectedCloakName}' not found in cloaks array.` - ); - } - }); - } -}); - -// this initialize cloak settings -cloak.init(); - - diff --git a/public/uv/index.js b/public/uv/index.js index af6cf7b..075fda4 100644 --- a/public/uv/index.js +++ b/public/uv/index.js @@ -13,9 +13,8 @@ const errorCode = document.getElementById("uv-error-code"); "://" + location.host + "/wisp/"; - if ((await connection.getTransport()) !== "/epoxy/index.mjs") { - await connection.setTransport("/epoxy/index.mjs", [{ wisp: wispUrl }]); - } + + await connection.setTransport("/epoxy/index.mjs", [{ wisp: wispUrl }]); })(); try { diff --git a/public/views/index.ejs b/public/views/index.ejs index 519ddc2..6d01225 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -59,3 +59,4 @@ $("#version").text(`v${data.version}`); }); + diff --git a/public/views/layout.ejs b/public/views/layout.ejs index 42ea3bd..2dad0aa 100644 --- a/public/views/layout.ejs +++ b/public/views/layout.ejs @@ -28,7 +28,7 @@ - +