Skip to content

Commit

Permalink
caddy api, fix about blank
Browse files Browse the repository at this point in the history
  • Loading branch information
skysthelimitt committed May 12, 2024
1 parent 88809cc commit ffbaa45
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<a href="index.html">Home</a>
<a href="settings.html">Settings</a>
<a href="https://discord.gg/7jyufnwJNf">Selenite Discord</a>
<a id="openBlankLink">Open Blank</a>
<a id="blank">Open Blank</a>
</header>
<main id="main" class="noscroll">
<h1>selenite</h1>
Expand Down
13 changes: 13 additions & 0 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<style>*{margin:0;padding:0;border:none}body,iframe{height:100vh;width:100vw}iframe{height:96vh}header{display:flex;height:4vh;justify-content:center;}button{margin-right:100px;height:100%;aspect-ratio: 1 / 1}#reload{background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24'%3E%3Cpath d='M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z'/%3E%3C/svg%3E");background-size:cover;}#goBack{background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24'%3E%3Cpath d='M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z'/%3E%3C/svg%3E");background-size:cover;}</style><script>
</script><header><button id=goBack></button><button id=reload></button></header><iframe id=selenite></iframe>`;
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();
});

41 changes: 41 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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("<script>document.cookie = `password=${prompt('Enter the password')}`;location.reload();</script>");
Expand Down

0 comments on commit ffbaa45

Please sign in to comment.