From ffbaa45de903c1934f596a7defff13ccae44fd03 Mon Sep 17 00:00:00 2001 From: sky Date: Sun, 12 May 2024 16:28:44 -0400 Subject: [PATCH] caddy api, fix about blank --- public/index.html | 2 +- public/index.js | 13 +++++++++++++ src/index.js | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 500471c..e95120a 100644 --- a/public/index.html +++ b/public/index.html @@ -37,7 +37,7 @@ Home Settings Selenite Discord - Open Blank + Open Blank

selenite

diff --git a/public/index.js b/public/index.js index 64e0552..fd9e41f 100644 --- a/public/index.js +++ b/public/index.js @@ -37,3 +37,16 @@ form.addEventListener("submit", async (event) => { frame.style.display = "block"; frame.src = __uv$config.prefix + __uv$config.encodeUrl(url); }); +document.getElementById("blank").addEventListener("click", () => { + let win = window.open(); + win.document.body.style.margin = "0"; + win.document.body.style.height = "100vh"; + let html = ` +
`; + win.document.querySelector("html").innerHTML = html; + win.eval(`let selenite = document.getElementById("selenite");console.log(selenite);selenite.setAttribute("src", "${location.origin}");console.log(selenite);document.getElementById("goBack").addEventListener("click", function () {selenite.contentDocument.location.href = selenite.contentDocument.location.origin;});document.getElementById("reload").addEventListener("click", function () {selenite.contentDocument.location.href = selenite.contentDocument.location.href;})`); + location.href = "https://google.com"; + close(); +}); + diff --git a/src/index.js b/src/index.js index 60f7f30..2b1c2cf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,37 @@ +let links; +import path from 'node:path'; +import fs from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); +const filePath = path.join(__dirname, "api/some.pass"); +fs.readFile(filePath, "utf8", (err, data) => { + if (err) { + console.error(err); + return; + } + try { + links = Object.keys(JSON.parse(data)); + } catch (err) { + console.error("Error parsing JSON:", err); + } +}); +fs.watch(filePath, () => { + fs.readFile(filePath, "utf8", (err, data) => { + if (err) { + console.error(err); + return; + } + try { + links = Object.keys(JSON.parse(data)); + console.log("file change"); + } catch (err) { + console.error("Error parsing JSON:", err); + } + }); +}); import express from "express"; import { createServer } from "node:http"; import { uvPath } from "@titaniumnetwork-dev/ultraviolet"; @@ -22,6 +56,13 @@ app.post("/api/addLink", (req, res) => { res.sendStatus(401); } }); +app.use("/check", (req, res) => { + if(links.includes(req.query.domain)) { + res.sendStatus(200); + } else { + res.sendStatus(404); + } +}); app.use((req, res, next) => { if (!checkPass(req)) { res.send("");