Make eslint a bit stricter, and lint + format.
This commit is contained in:
parent
622855db01
commit
3806d64f66
24 changed files with 2104 additions and 2109 deletions
|
|
@ -12,7 +12,10 @@ module.exports = {
|
|||
rules: {
|
||||
"no-unused-vars": "error",
|
||||
"no-undef": "off",
|
||||
"prefer-const": "error",
|
||||
"no-case-declarations": "off",
|
||||
},
|
||||
ignorePatterns: ["env.d.ts"],
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.astro"],
|
||||
|
|
@ -22,6 +25,17 @@ module.exports = {
|
|||
extraFileExtensions: [".astro"],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["*.ts", "*.tsx"],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
extends: [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
],
|
||||
},
|
||||
{
|
||||
// Define the configuration for `<script>` tag.
|
||||
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
|
||||
|
|
|
|||
2
index.js
2
index.js
|
|
@ -132,7 +132,7 @@ app.get("*", (req, res) => {
|
|||
res.sendFile(path.join(process.cwd(), "dist/client/404.html"));
|
||||
});
|
||||
|
||||
let server = createServer();
|
||||
const server = createServer();
|
||||
server.on("request", (req, res) => {
|
||||
if (bare.shouldRoute(req)) {
|
||||
bare.routeRequest(req, res);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import path from "path";
|
||||
import fs from "fs";
|
||||
export async function masqrCheck(config, htmlFile) {
|
||||
let loadedHTMLFile = fs.readFileSync(htmlFile, "utf8");
|
||||
const loadedHTMLFile = fs.readFileSync(htmlFile, "utf8");
|
||||
return async (req, res, next) => {
|
||||
if (req.headers.host && config.whitelist.includes(req.headers.host)) {
|
||||
next();
|
||||
|
|
@ -37,8 +37,8 @@ async function MasqFail(req, res, failureFile) {
|
|||
return;
|
||||
}
|
||||
const unsafeSuffix = req.headers.host + ".html";
|
||||
let safeSuffix = path.normalize(unsafeSuffix).replace(/^(\.\.(\/|\\|$))+/, "");
|
||||
let safeJoin = path.join(process.cwd() + "/Masqrd", safeSuffix);
|
||||
const safeSuffix = path.normalize(unsafeSuffix).replace(/^(\.\.(\/|\\|$))+/, "");
|
||||
const safeJoin = path.join(process.cwd() + "/Masqrd", safeSuffix);
|
||||
try {
|
||||
await fs.promises.access(safeJoin); // man do I wish this was an if-then instead of a "exception on fail"
|
||||
const failureFileLocal = await fs.promises.readFile(safeJoin, "utf8");
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
"build": "astro build",
|
||||
"format": "prettier --write .",
|
||||
"format:check": "prettier --check .",
|
||||
"lint": "eslint ."
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint --fix ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^8.2.5",
|
||||
|
|
|
|||
3721
pnpm-lock.yaml
generated
3721
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,8 +1,8 @@
|
|||
<script>
|
||||
function loadCloak() {
|
||||
let localStorageCloak = localStorage.getItem("alu__selectedCloak");
|
||||
const localStorageCloak = localStorage.getItem("alu__selectedCloak");
|
||||
if (localStorageCloak) {
|
||||
let parsedCloak = JSON.parse(localStorageCloak);
|
||||
const parsedCloak = JSON.parse(localStorageCloak);
|
||||
if (parsedCloak) {
|
||||
if (parsedCloak.name != "None") {
|
||||
document.title = parsedCloak.name;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
import { Notyf } from "notyf";
|
||||
import { loadIDB, GetStore, ValidateStoreExists, CreateStore } from "./ts/IDBManager";
|
||||
|
||||
let form = document.querySelector("form");
|
||||
const form = document.querySelector("form");
|
||||
let input = document.querySelector("input");
|
||||
document.addEventListener("astro:after-swap", initForm);
|
||||
function initForm() {
|
||||
let formEle = document.querySelector("form");
|
||||
const formEle = document.querySelector("form");
|
||||
input = document.querySelector("input");
|
||||
if (formEle) formEle.addEventListener("submit", formEventListener);
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
}
|
||||
|
||||
setInterval(() => {
|
||||
let iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
const iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
if (iframe && iframe.src != "") {
|
||||
updateProxiedFavicon(iframe);
|
||||
updateTopbarTitle(iframe);
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
}, 500);
|
||||
|
||||
async function getProxyURL() {
|
||||
let preference = getProxyPreference();
|
||||
const preference = getProxyPreference();
|
||||
let url = input!.value.trim();
|
||||
if (!isUrl(url)) url = getSearchEngine() + url;
|
||||
else if (!(url.startsWith("https://") || url.startsWith("http://"))) url = "http://" + url;
|
||||
|
|
@ -33,10 +33,10 @@
|
|||
return window.__uv$config.prefix + window.__uv$config.encodeUrl(url);
|
||||
} else if (preference == "rammerhead") {
|
||||
// Check if rammerhead-session exists in cookies
|
||||
let rammerheadSession = getCookie("rammerhead-session");
|
||||
const rammerheadSession = getCookie("rammerhead-session");
|
||||
if (!rammerheadSession) {
|
||||
let session = await fetch("/newsession");
|
||||
let sessionID = await session.text();
|
||||
const session = await fetch("/newsession");
|
||||
const sessionID = await session.text();
|
||||
await fetch("/editsession?id=" + sessionID + "&enableShuffling=0");
|
||||
// Now save it in a cookie that expires in 72 hours.
|
||||
document.cookie = `rammerhead-session=${sessionID}; max-age=${60 * 60 * 72}; path=/`;
|
||||
|
|
@ -54,16 +54,16 @@
|
|||
|
||||
async function loadPageExtensions() {
|
||||
try {
|
||||
let iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
const iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
if (!ValidateStoreExists("InstalledExtensions")) {
|
||||
CreateStore("InstalledExtensions", { keyPath: "slug" });
|
||||
}
|
||||
let db = loadIDB("AluDB", 1);
|
||||
const db = loadIDB("AluDB", 1);
|
||||
db.onsuccess = () => {
|
||||
let store = GetStore("InstalledExtensions", "readonly");
|
||||
let request = store.getAll();
|
||||
const store = GetStore("InstalledExtensions", "readonly");
|
||||
const request = store.getAll();
|
||||
request.onsuccess = () => {
|
||||
let extensions = request.result;
|
||||
const extensions = request.result;
|
||||
extensions.forEach((extension: IExtensionMetadata) => {
|
||||
// Eval the extension script inside of the iframe
|
||||
if (!(extension.type == "page")) return;
|
||||
|
|
@ -73,8 +73,8 @@
|
|||
console.log(url);
|
||||
console.log(iframe.contentWindow!.__uv$location.host);
|
||||
if (iframe.contentWindow!.__uv$location.host.includes(url)) {
|
||||
let script = extension.script;
|
||||
let scriptElement = document.createElement("script");
|
||||
const script = extension.script;
|
||||
const scriptElement = document.createElement("script");
|
||||
scriptElement.src = script;
|
||||
scriptElement.type = "module";
|
||||
iframe.contentDocument!.head.appendChild(scriptElement);
|
||||
|
|
@ -89,30 +89,30 @@
|
|||
}
|
||||
}
|
||||
|
||||
async function loadContent() {
|
||||
async function loadContent(): Promise<void> {
|
||||
await initTransport();
|
||||
await loadPageExtensions();
|
||||
// The setTimeout is because service workers are a little silly and can take a while longer to register despite .then being called, which causes a bug on the first load.
|
||||
setTimeout(async () => {
|
||||
let openWith = localStorage.getItem("alu__selectedOpenWith");
|
||||
let currentProxy = localStorage.getItem("alu__selectedProxy");
|
||||
const openWith = localStorage.getItem("alu__selectedOpenWith");
|
||||
const currentProxy = localStorage.getItem("alu__selectedProxy");
|
||||
let url = input!.value.trim();
|
||||
if (!isUrl(url)) url = getSearchEngine() + url;
|
||||
else if (!(url.startsWith("https://") || url.startsWith("http://"))) url = "http://" + url;
|
||||
if (openWith) {
|
||||
let openWithParsed = JSON.parse(openWith);
|
||||
const openWithParsed = JSON.parse(openWith);
|
||||
if (openWithParsed.value === "newTab" || (currentProxy && JSON.parse(currentProxy).value === "rammerhead")) {
|
||||
window.open(await getProxyURL(), "_blank");
|
||||
return;
|
||||
}
|
||||
if (openWithParsed.value === "about:blank") {
|
||||
// Open about:blank window and inject iframe into it
|
||||
let newWindow = window.open("about:blank", "_blank");
|
||||
let newWindowDocument = newWindow!.document;
|
||||
let iframe = newWindowDocument.createElement("iframe");
|
||||
const newWindow = window.open("about:blank", "_blank");
|
||||
const newWindowDocument = newWindow!.document;
|
||||
const iframe = newWindowDocument.createElement("iframe");
|
||||
iframe.src = await getProxyURL();
|
||||
// Inject css into the iframe
|
||||
let css = newWindowDocument.createElement("link");
|
||||
const css = newWindowDocument.createElement("link");
|
||||
css.rel = "stylesheet";
|
||||
css.href = "/iframe.css";
|
||||
newWindowDocument.head.appendChild(css);
|
||||
|
|
@ -120,24 +120,24 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
let loadingContent = document.getElementById("loading-content") as HTMLElement;
|
||||
const loadingContent = document.getElementById("loading-content") as HTMLElement;
|
||||
if (loadingContent) loadingContent.style.opacity = "1";
|
||||
|
||||
let iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
let topbar = document.getElementById("top-bar") as HTMLDivElement;
|
||||
let closeButton = document.getElementById("close-button") as HTMLButtonElement;
|
||||
let backwardsButton = document.getElementById("nav-backwards") as HTMLImageElement;
|
||||
let forwardsButton = document.getElementById("nav-forwards") as HTMLImageElement;
|
||||
let shareButton = document.getElementById("nav-share") as HTMLImageElement;
|
||||
let preference = getProxyPreference();
|
||||
const iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
const topbar = document.getElementById("top-bar") as HTMLDivElement;
|
||||
const closeButton = document.getElementById("close-button") as HTMLButtonElement;
|
||||
const backwardsButton = document.getElementById("nav-backwards") as HTMLImageElement;
|
||||
const forwardsButton = document.getElementById("nav-forwards") as HTMLImageElement;
|
||||
const shareButton = document.getElementById("nav-share") as HTMLImageElement;
|
||||
const preference = getProxyPreference();
|
||||
if (preference === "ultraviolet") {
|
||||
iframe.src = window.__uv$config.prefix + window.__uv$config.encodeUrl(url);
|
||||
} else if (preference == "rammerhead") {
|
||||
// Check if rammerhead-session exists in cookies
|
||||
let rammerheadSession = getCookie("rammerhead-session");
|
||||
const rammerheadSession = getCookie("rammerhead-session");
|
||||
if (!rammerheadSession) {
|
||||
let session = await fetch("/newsession");
|
||||
let sessionID = await session.text();
|
||||
const session = await fetch("/newsession");
|
||||
const sessionID = await session.text();
|
||||
// Disable URL shuffling on rewrite, eventually I'll try and figure out how it works, but for now, it's disabled.
|
||||
await fetch("/editsession?id=" + sessionID + "&enableShuffling=0");
|
||||
// Now save it in a cookie that expires in 72 hours.
|
||||
|
|
@ -192,8 +192,8 @@
|
|||
}
|
||||
};
|
||||
shareButton.onclick = () => {
|
||||
let currentProxy = localStorage.getItem("alu__selectedProxy");
|
||||
let proxyFrame = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
const currentProxy = localStorage.getItem("alu__selectedProxy");
|
||||
const proxyFrame = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||
if (currentProxy && JSON.parse(currentProxy).value === "rammerhead") {
|
||||
navigator.clipboard.writeText(window.location.origin + "/" + getCookie("rammerhead-session") + "/" + input!.value.trim());
|
||||
} else {
|
||||
|
|
@ -239,7 +239,7 @@
|
|||
}
|
||||
|
||||
function getSearchEngine() {
|
||||
let localStorageSearchEngine = localStorage.getItem("alu__search_engine");
|
||||
const localStorageSearchEngine = localStorage.getItem("alu__search_engine");
|
||||
if (!localStorageSearchEngine) {
|
||||
return "https://google.com/search?q=";
|
||||
}
|
||||
|
|
@ -269,7 +269,7 @@
|
|||
}
|
||||
|
||||
function getProxyPreference() {
|
||||
let localStorageItem = localStorage.getItem("alu__selectedProxy");
|
||||
const localStorageItem = localStorage.getItem("alu__selectedProxy");
|
||||
|
||||
if (!localStorageItem) return "uv";
|
||||
|
||||
|
|
@ -285,15 +285,15 @@
|
|||
|
||||
function updateProxiedFavicon(iframe: HTMLIFrameElement) {
|
||||
if (!iframe) return;
|
||||
let proxiedFavicon = document.getElementById("proxied-favicon") as HTMLImageElement;
|
||||
const proxiedFavicon = document.getElementById("proxied-favicon") as HTMLImageElement;
|
||||
if (iframe) {
|
||||
if (iframe.contentDocument) {
|
||||
let favicon = (iframe.contentDocument.querySelector("link[rel='icon']") as HTMLLinkElement) || (iframe.contentDocument.querySelector("link[rel*='icon']") as HTMLLinkElement);
|
||||
const favicon = (iframe.contentDocument.querySelector("link[rel='icon']") as HTMLLinkElement) || (iframe.contentDocument.querySelector("link[rel*='icon']") as HTMLLinkElement);
|
||||
if (favicon && favicon.href.includes("data:image")) {
|
||||
proxiedFavicon.src = favicon.href;
|
||||
return;
|
||||
}
|
||||
let UVURL = getUVProxyURL(iframe);
|
||||
const UVURL = getUVProxyURL(iframe);
|
||||
if (proxiedFavicon.src == `${window.location.origin}/custom-favicon?url=${UVURL}`) return;
|
||||
proxiedFavicon.src = `/custom-favicon?url=${UVURL}`;
|
||||
loadPageExtensions();
|
||||
|
|
@ -302,7 +302,7 @@
|
|||
}
|
||||
function updateTopbarTitle(iframe: HTMLIFrameElement) {
|
||||
if (!iframe.contentDocument) return;
|
||||
let topbarTitle = document.getElementById("url-text") as HTMLElement;
|
||||
const topbarTitle = document.getElementById("url-text") as HTMLElement;
|
||||
if (iframe.contentDocument.title == "") {
|
||||
topbarTitle.innerText = "Loading...";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const themeList = [
|
|||
const languageList = [
|
||||
{ name: "English", value: "en" },
|
||||
{ name: "日本語", value: "jp" },
|
||||
{ name: "Français", value: "fr"}
|
||||
{ name: "Français", value: "fr" },
|
||||
];
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
import IDBManager from "@components/ts/IDBManager";
|
||||
|
||||
function switchTheme() {
|
||||
let currentTheme = localStorage.getItem("alu__selectedTheme");
|
||||
const currentTheme = localStorage.getItem("alu__selectedTheme");
|
||||
|
||||
if (currentTheme) {
|
||||
document.documentElement.setAttribute("data-theme", JSON.parse(currentTheme).value.toLowerCase());
|
||||
let footer = document.getElementById("footer");
|
||||
const footer = document.getElementById("footer");
|
||||
if (footer) {
|
||||
footer.dataset.theme = JSON.parse(currentTheme).value.toLowerCase();
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
const idb = IDBManager.loadIDB("AluDB", 1);
|
||||
|
||||
idb.onsuccess = () => {
|
||||
let store = IDBManager.GetStore("InstalledExtensions", "readonly");
|
||||
const store = IDBManager.GetStore("InstalledExtensions", "readonly");
|
||||
store.getAll().onsuccess = (event) => {
|
||||
const result = (event.target as IDBRequest).result;
|
||||
if (result) {
|
||||
|
|
|
|||
|
|
@ -10,16 +10,21 @@ if (defaultStyles) {
|
|||
interface Props {
|
||||
inputName: string;
|
||||
defaultTextContent?: string;
|
||||
height: string;
|
||||
height?: string;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
defaultStyles?: boolean;
|
||||
autocomplete?: string;
|
||||
}
|
||||
|
||||
let inputHeight = height;
|
||||
if (!height) {
|
||||
inputHeight = "3rem";
|
||||
}
|
||||
---
|
||||
|
||||
<input
|
||||
style={`height: ${height}`}
|
||||
style={`height: ${inputHeight}`}
|
||||
id={inputName + "-input"}
|
||||
placeholder={placeholder || ""}
|
||||
value={defaultTextContent || ""}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
let primaryColor = "#8c25fa";
|
||||
let secondaryColor = "#601aab";
|
||||
const primaryColor = "#8c25fa";
|
||||
const secondaryColor = "#601aab";
|
||||
console.log("%cWelcome to Alu", `color: ${primaryColor}; font-size: 2rem; font-weight: bold; text-shadow: 2px 2px 0 ${secondaryColor};`);
|
||||
|
||||
console.log("%cSystem Information: ", `color: ${primaryColor}; font-size: 1rem; font-weight: bold;`);
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ export function loadIDBPromise(name: string, version: number): Promise<IDBDataba
|
|||
reject(event);
|
||||
};
|
||||
|
||||
request.onsuccess = (event) => {
|
||||
request.onsuccess = () => {
|
||||
const idb = request.result;
|
||||
CurrentIDB = idb;
|
||||
resolve(idb);
|
||||
};
|
||||
|
||||
request.onupgradeneeded = (event) => {
|
||||
request.onupgradeneeded = () => {
|
||||
const idb = request.result;
|
||||
CurrentIDB = idb;
|
||||
resolve(idb);
|
||||
|
|
@ -34,7 +34,7 @@ export function loadIDBPromise(name: string, version: number): Promise<IDBDataba
|
|||
export function loadIDB(name: string, version: number): IDBOpenDBRequest {
|
||||
const request = window.indexedDB.open(name, version);
|
||||
|
||||
request.onblocked = (event) => {
|
||||
request.onblocked = () => {
|
||||
console.error("Database upgrade is blocked by another connection");
|
||||
};
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ export function DeleteIDB(name: string): Promise<IDBOpenDBRequest | Event> {
|
|||
reject(event);
|
||||
};
|
||||
|
||||
request.onsuccess = (event) => {
|
||||
request.onsuccess = () => {
|
||||
resolve(request);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ type transportConfig =
|
|||
export const wispURLDefault = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
export default class TransportManager {
|
||||
connection: BareMuxConnection;
|
||||
private transport = "/epoxy/index.mjs";
|
||||
private transport: string = "/epoxy/index.mjs";
|
||||
|
||||
constructor(transport?: string) {
|
||||
this.connection = new BareMuxConnection("/baremux/worker.js");
|
||||
|
|
@ -18,7 +18,8 @@ export default class TransportManager {
|
|||
this.transport = transport;
|
||||
}
|
||||
if (localStorage.getItem("alu__selectedTransport") != null && !transport) {
|
||||
this.transport = JSON.parse(localStorage.getItem("alu__selectedTransport")!).value;
|
||||
const selectedTransport = JSON.parse(localStorage.getItem("alu__selectedTransport")!) as { value: string };
|
||||
this.transport = selectedTransport.value;
|
||||
}
|
||||
if (localStorage.getItem("alu__selectedTransport") == null) {
|
||||
// Set the default transport for the next reload.
|
||||
|
|
@ -27,10 +28,11 @@ export default class TransportManager {
|
|||
}
|
||||
async updateTransport() {
|
||||
try {
|
||||
await this.setTransport(JSON.parse(localStorage.getItem("alu__selectedTransport")!).value);
|
||||
const selectedTransport = JSON.parse(localStorage.getItem("alu__selectedTransport")!) as { value: string };
|
||||
await this.setTransport(selectedTransport.value);
|
||||
} catch {
|
||||
console.log("Failed to update transport! Falling back to old transport.");
|
||||
this.setTransport(this.transport);
|
||||
await this.setTransport(this.transport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -52,21 +54,19 @@ export default class TransportManager {
|
|||
|
||||
export const TransportMgr = new TransportManager();
|
||||
|
||||
export async function registerAndUpdateSW() {
|
||||
return new Promise(async (resolve) => {
|
||||
navigator.serviceWorker
|
||||
.register("/sw.js", {
|
||||
updateViaCache: "none",
|
||||
})
|
||||
.then(async (reg) => {
|
||||
console.log("Service worker registered!");
|
||||
reg.update();
|
||||
|
||||
resolve(null);
|
||||
});
|
||||
});
|
||||
export async function registerAndUpdateSW(): Promise<void> {
|
||||
try {
|
||||
const reg = await navigator.serviceWorker.register("/sw.js", {
|
||||
updateViaCache: "none",
|
||||
});
|
||||
console.log("Service worker registered!");
|
||||
await reg.update();
|
||||
} catch (err) {
|
||||
console.error("Service worker registration failed: ", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function initTransport() {
|
||||
await TransportMgr.setTransport(TransportMgr.getTransport(), localStorage.getItem("alu__wispUrl") || wispURLDefault);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
export async function testWispServers(servers: WispServer[]): Promise<WispData[]> {
|
||||
let wispData: WispData[] = [];
|
||||
const wispData: WispData[] = [];
|
||||
|
||||
for (const server of servers) {
|
||||
let start = performance.now();
|
||||
const start = performance.now();
|
||||
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
let socket = new WebSocket(server.url);
|
||||
const socket = new WebSocket(server.url);
|
||||
|
||||
socket.onopen = () => {
|
||||
let end = performance.now();
|
||||
const end = performance.now();
|
||||
console.log(`Connected to ${server.url} in ${end - start}ms`);
|
||||
let data = {
|
||||
const data = {
|
||||
server: server,
|
||||
time: end - start,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
export async function retrieveExtensions(type: ExtType) {
|
||||
const extensionsArr: Array<Extension> = [];
|
||||
const db = await new Promise<IDBDatabase>((resolve, reject) => {
|
||||
const request = indexedDB.open("AluDB", 1);
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = reject;
|
||||
});
|
||||
|
||||
const transaction = db.transaction("InstalledExtensions", "readwrite");
|
||||
const objectStore = transaction.objectStore("InstalledExtensions");
|
||||
const extensions: Array<Extension> = await new Promise((resolve, reject) => {
|
||||
const request = objectStore.getAll();
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = reject;
|
||||
});
|
||||
|
||||
extensions.forEach(async (extension: Extension) => {});
|
||||
return extensionsArr;
|
||||
}
|
||||
|
|
@ -19,15 +19,15 @@ Array.from(installButtons).forEach((btn) => {
|
|||
btn.addEventListener("click", async (event) => {
|
||||
const ele = event.target as HTMLButton;
|
||||
const title = ele.dataset.title;
|
||||
let notification = new Notyf({
|
||||
const notification = new Notyf({
|
||||
duration: 999999,
|
||||
position: { x: "right", y: "bottom" },
|
||||
dismissible: true,
|
||||
ripple: true,
|
||||
});
|
||||
let installNotif = notification.success(`Installing ${title}...`);
|
||||
const installNotif = notification.success(`Installing ${title}...`);
|
||||
if (ele.dataset.slug) {
|
||||
let obj = await getMarketplaceObj(ele.dataset.slug);
|
||||
const obj = await getMarketplaceObj(ele.dataset.slug);
|
||||
installExtension(obj, ele.dataset.slug)
|
||||
.then((ret) => {
|
||||
let notifMessage: string;
|
||||
|
|
@ -63,7 +63,7 @@ Array.from(installButtons).forEach((btn) => {
|
|||
window.location.reload();
|
||||
}, 1000);
|
||||
notification.options.duration = 999999;
|
||||
let btn = document.querySelector(`button[data-slug="${ret.slug}"]`) as HTMLButton;
|
||||
const btn = document.querySelector(`button[data-slug="${ret.slug}"]`) as HTMLButton;
|
||||
setInstallBtnText(btn);
|
||||
}, timeout);
|
||||
})
|
||||
|
|
@ -96,7 +96,7 @@ async function installExtension(ext: IExtensionMetadata, slug: string): Promise<
|
|||
slug: slug,
|
||||
...ext,
|
||||
};
|
||||
let slugCheck = store.get(slug);
|
||||
const slugCheck = store.get(slug);
|
||||
slugCheck.onsuccess = async () => {
|
||||
if (slugCheck.result != null) {
|
||||
resolve({ code: EXT_RETURN.ALREADY_INSTALLED, slug: slug });
|
||||
|
|
@ -120,8 +120,8 @@ function addUninstallEventListeners() {
|
|||
if (!confirm("Are you sure you want to uninstall this extension?")) {
|
||||
return;
|
||||
}
|
||||
let uninst = await uninstallExtension((event.target as HTMLButton).dataset.uninstallSlug!);
|
||||
let notification = new Notyf({
|
||||
const uninst = await uninstallExtension((event.target as HTMLButton).dataset.uninstallSlug!);
|
||||
const notification = new Notyf({
|
||||
duration: 999999,
|
||||
position: { x: "right", y: "bottom" },
|
||||
dismissible: true,
|
||||
|
|
@ -130,7 +130,7 @@ function addUninstallEventListeners() {
|
|||
switch (uninst.code) {
|
||||
case EXT_RETURN.ACTION_SUCCESS:
|
||||
notification.success(`Uninstalled ${uninst.title}!`);
|
||||
let btn = document.querySelector(`button[data-slug="${uninst.slug}"]`) as HTMLButton;
|
||||
const btn = document.querySelector(`button[data-slug="${uninst.slug}"]`) as HTMLButton;
|
||||
btn.disabled = false;
|
||||
btn.textContent = "Install";
|
||||
btn.classList.remove("installed");
|
||||
|
|
@ -161,15 +161,15 @@ async function uninstallExtension(slug: string): Promise<InstallReturn> {
|
|||
const transaction = request.transaction("InstalledExtensions", "readwrite");
|
||||
const store = transaction.objectStore("InstalledExtensions");
|
||||
|
||||
let ext = store.get(slug);
|
||||
const ext = store.get(slug);
|
||||
ext.onsuccess = async () => {
|
||||
if (ext.result == null) {
|
||||
reject({ code: EXT_RETURN.INSTALL_FAILED, slug: slug });
|
||||
}
|
||||
if (ext.result.type === "theme") {
|
||||
let currTheme = localStorage.getItem("alu__selectedTheme");
|
||||
const currTheme = localStorage.getItem("alu__selectedTheme");
|
||||
if (currTheme) {
|
||||
if (JSON.parse(currTheme!).value == ext.result.themeName) {
|
||||
if (JSON.parse(currTheme).value == ext.result.themeName) {
|
||||
console.log("Reverting theme to default!");
|
||||
localStorage.setItem("alu__selectedTheme", JSON.stringify({ name: "Alu", value: "alu" }));
|
||||
}
|
||||
|
|
@ -201,17 +201,18 @@ function setInstallBtnText(btn: HTMLButton) {
|
|||
}
|
||||
|
||||
function getInstallStatus() {
|
||||
let installBtns = document.querySelectorAll("button[data-slug]") as NodeListOf<HTMLButton>;
|
||||
let transaction = IDBManager.GetStore("InstalledExtensions", "readonly").transaction;
|
||||
let store = transaction.objectStore("InstalledExtensions");
|
||||
let cursor = store.openCursor();
|
||||
const installBtns = document.querySelectorAll("button[data-slug]");
|
||||
const transaction = IDBManager.GetStore("InstalledExtensions", "readonly").transaction;
|
||||
const store = transaction.objectStore("InstalledExtensions");
|
||||
const cursor = store.openCursor();
|
||||
cursor.onsuccess = () => {
|
||||
let res = cursor.result;
|
||||
const res = cursor.result;
|
||||
if (res) {
|
||||
let slug = res.value.slug;
|
||||
const slug = res.value.slug;
|
||||
installBtns.forEach((btn) => {
|
||||
if (btn.dataset.slug == slug) {
|
||||
setInstallBtnText(btn);
|
||||
const button = btn as HTMLButton;
|
||||
if (button.dataset.slug == slug) {
|
||||
setInstallBtnText(button);
|
||||
document.querySelector(`button[data-uninstall-slug="${slug}"]`)!.classList.remove("btn-hidden");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function inferLangUseTranslations(url: URL) {
|
|||
|
||||
function useTranslations(lang: LanguageKeys) {
|
||||
return function t(translationKey: TranslationKeys) {
|
||||
let key = ui[lang][translationKey];
|
||||
const key = ui[lang][translationKey];
|
||||
if (key) return key;
|
||||
else return ui[defaultLang][translationKey];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ const { title, optionalPreloads } = Astro.props;
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link href="/varela-round.css" rel="stylesheet" />
|
||||
<ThemeLoader transition:persist />
|
||||
<CloakLoader transition:persist />
|
||||
<meta charset="UTF-8" />
|
||||
|
|
@ -39,7 +40,6 @@ const { title, optionalPreloads } = Astro.props;
|
|||
<meta property="twitter:description" content="Alu is a sleek web proxy supporting multiple standards of communication, and wide levels of customization." />
|
||||
<meta property="twitter:image" content="/logo.png" />
|
||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
<link href="/varela-round.css" rel="stylesheet" as="style" />
|
||||
{
|
||||
optionalPreloads?.map((item) => {
|
||||
return <link rel="preload" href={item.href} as={item.as} />;
|
||||
|
|
@ -58,12 +58,11 @@ const { title, optionalPreloads } = Astro.props;
|
|||
<script>
|
||||
import IDBManager from "@components/ts/IDBManager";
|
||||
if (!window.idb) {
|
||||
let db = await IDBManager.loadIDBPromise("AluDB", 1);
|
||||
const db = await IDBManager.loadIDBPromise("AluDB", 1);
|
||||
if (db instanceof IDBDatabase) {
|
||||
window.idb = db;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>{title}</title>
|
||||
|
|
@ -110,6 +109,39 @@ const { title, optionalPreloads } = Astro.props;
|
|||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.url-input-form {
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.url-input.search-results {
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.url-input::placeholder {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.url-input {
|
||||
display: block;
|
||||
background: transparent url(/img/search.svg) no-repeat 1rem center;
|
||||
background-color: var(--dropdown-background-color);
|
||||
color: var(--text-color);
|
||||
border: 2px solid var(--text-color);
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
transition: 0.25s ease-in-out;
|
||||
outline: none;
|
||||
font-family:
|
||||
Varela Round,
|
||||
sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
[data-theme="mocha"] {
|
||||
/* Catppucin Mocha theme */
|
||||
--background-color: #1e1e2e;
|
||||
|
|
@ -266,7 +298,6 @@ const { title, optionalPreloads } = Astro.props;
|
|||
}
|
||||
|
||||
.nav-container > img {
|
||||
height: 32px;
|
||||
cursor: pointer;
|
||||
transition: 250ms ease-in-out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ export function getStaticPaths() {
|
|||
</Layout>
|
||||
|
||||
<script>
|
||||
let search = document.getElementById("games-search-input") as HTMLInputElement;
|
||||
let mainContent = document.getElementById("main-content") as HTMLDivElement;
|
||||
const search = document.getElementById("games-search-input") as HTMLInputElement;
|
||||
const mainContent = document.getElementById("main-content") as HTMLDivElement;
|
||||
search.addEventListener("input", () => {
|
||||
let filter = search.value.toUpperCase();
|
||||
let games = mainContent.children;
|
||||
const filter = search.value.toUpperCase();
|
||||
const games = mainContent.children;
|
||||
let results = 0;
|
||||
for (let i = 0; i < games.length; i++) {
|
||||
let game = games[i] as HTMLDivElement;
|
||||
let name = game.getAttribute("data-name")!;
|
||||
const game = games[i] as HTMLDivElement;
|
||||
const name = game.getAttribute("data-name")!;
|
||||
if (name.toUpperCase().indexOf(filter) > -1) {
|
||||
game.style.display = "";
|
||||
results++;
|
||||
|
|
@ -47,13 +47,13 @@ export function getStaticPaths() {
|
|||
}
|
||||
console.log(results);
|
||||
if (results === 0) {
|
||||
let noResults = document.querySelector(".no-results") as HTMLDivElement;
|
||||
const noResults = document.querySelector(".no-results") as HTMLDivElement;
|
||||
if (noResults) {
|
||||
noResults.style.display = "block";
|
||||
noResults.innerHTML = "No results found";
|
||||
}
|
||||
} else {
|
||||
let noResults = document.querySelector(".no-results") as HTMLDivElement;
|
||||
const noResults = document.querySelector(".no-results") as HTMLDivElement;
|
||||
if (noResults) {
|
||||
noResults.style.display = "none";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export function getStaticPaths() {
|
|||
<section id="proxy-input">
|
||||
<div class="form-wrapper">
|
||||
<form class="url-input-form" id="url-input-form">
|
||||
<Input className="url-input" inputName="url" height="50px" placeholder={t("menu.search")} defaultStyles={false} transition:persist autocomplete="off" />
|
||||
<Input className="url-input" inputName="url" placeholder={t("menu.search")} defaultStyles={false} transition:persist autocomplete="off" />
|
||||
<div id="search-suggestions"></div>
|
||||
<div id="loading-content">Loading...</div>
|
||||
</form>
|
||||
|
|
@ -26,9 +26,9 @@ export function getStaticPaths() {
|
|||
<div class="top-bar-left">
|
||||
<button id="close-button">Close</button>
|
||||
<div class="nav-container">
|
||||
<img id="nav-backwards" src="/img/nav/backwards.svg" alt="Backwards Arrow" />
|
||||
<img id="nav-forwards" src="/img/nav/forwards.svg" alt="Forwards Arrow" />
|
||||
<img id="nav-share" src="/img/nav/share.svg" alt="Share Page" />
|
||||
<img width="32px" height="32px" id="nav-backwards" src="/img/nav/backwards.svg" alt="Backwards Arrow" />
|
||||
<img width="32px" height="32px" id="nav-forwards" src="/img/nav/forwards.svg" alt="Forwards Arrow" />
|
||||
<img width="32px" height="32px" id="nav-share" src="/img/nav/share.svg" alt="Share Page" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="top-bar-right">
|
||||
|
|
@ -73,20 +73,19 @@ export function getStaticPaths() {
|
|||
async function sendAPIRequest(urlInput: HTMLInputElement, searchSuggestions: HTMLDivElement) {
|
||||
if (!urlInput) throw new Error("urlInput is null");
|
||||
if (!searchSuggestions) throw new Error("searchSuggestions is null");
|
||||
let url = urlInput.value;
|
||||
let request = await fetch("/search?query=" + url);
|
||||
let data = await request.json();
|
||||
const url = urlInput.value;
|
||||
const request = await fetch("/search?query=" + url);
|
||||
const data = await request.json();
|
||||
searchSuggestions.innerHTML = "";
|
||||
data.map((suggestion: Suggestion) => {
|
||||
let suggestionElement = document.createElement("div");
|
||||
const suggestionElement = document.createElement("div");
|
||||
// For some reason css classes weren't working T^T.
|
||||
suggestionElement.style.cursor = "pointer";
|
||||
suggestionElement.style.marginTop = "5px";
|
||||
suggestionElement.innerText = suggestion.phrase;
|
||||
suggestionElement.addEventListener("click", async () => {
|
||||
urlInput.value = suggestion.phrase;
|
||||
if (window.loadSelectedTransport) await window.loadSelectedTransport();
|
||||
if (window.loadFormContent) window.loadFormContent(suggestion.phrase);
|
||||
if (window.loadFormContent) window.loadFormContent();
|
||||
});
|
||||
searchSuggestions.appendChild(suggestionElement);
|
||||
});
|
||||
|
|
@ -100,8 +99,8 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function addEventListeners() {
|
||||
let urlInput = document.getElementById("url-input") as HTMLInputElement;
|
||||
let searchSuggestions = document.getElementById("search-suggestions") as HTMLDivElement;
|
||||
const urlInput = document.getElementById("url-input") as HTMLInputElement;
|
||||
const searchSuggestions = document.getElementById("search-suggestions") as HTMLDivElement;
|
||||
// Silently return if the required elements aren't found, this prevents the console from getting cluttered with errors.
|
||||
if (!urlInput || !searchSuggestions) return;
|
||||
urlInput.addEventListener("focus", () => {
|
||||
|
|
@ -145,39 +144,8 @@ export function getStaticPaths() {
|
|||
justify-content: center;
|
||||
}
|
||||
form {
|
||||
width: 350px;
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
.url-input-form {
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.url-input {
|
||||
display: block;
|
||||
background: transparent url("/img/search.svg") no-repeat 13px center;
|
||||
background-color: var(--dropdown-background-color);
|
||||
color: var(--text-color);
|
||||
border: 3px solid var(--text-color);
|
||||
border-radius: 30px;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
transition: 250ms ease-in-out;
|
||||
outline: none;
|
||||
font-family: "Varela Round", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.url-input.search-results {
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.url-input::placeholder {
|
||||
color: var(--text-color);
|
||||
width: 30%;
|
||||
height: 4rem;
|
||||
}
|
||||
|
||||
#search-suggestions {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export function getStaticPaths() {
|
|||
window.currentlySelectedTab = "";
|
||||
});
|
||||
Array.from(document.getElementsByClassName("setting-tab")).forEach((tab) => {
|
||||
let contentToLoad = document.getElementById("content-" + tab.id);
|
||||
const contentToLoad = document.getElementById("content-" + tab.id);
|
||||
if (contentToLoad) {
|
||||
window.loadedContentStorage[tab.id] = contentToLoad.innerHTML;
|
||||
contentToLoad.remove();
|
||||
|
|
@ -77,7 +77,7 @@ export function getStaticPaths() {
|
|||
function loadContent(tabID) {
|
||||
if (window.currentlySelectedTab == tabID) return;
|
||||
else window.currentlySelectedTab = tabID;
|
||||
let currentContent = document.getElementById("current-content");
|
||||
const currentContent = document.getElementById("current-content");
|
||||
if (currentContent) {
|
||||
currentContent.style.opacity = "0";
|
||||
setTimeout(() => {
|
||||
|
|
@ -89,7 +89,7 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function addDropdownListener() {
|
||||
let dropdown_toggles = document.getElementsByClassName("dropdown-toggle");
|
||||
const dropdown_toggles = document.getElementsByClassName("dropdown-toggle");
|
||||
Array.from(dropdown_toggles).forEach((toggle) => {
|
||||
toggle.onclick = function () {
|
||||
closeOtherDropdowns(toggle.id);
|
||||
|
|
@ -99,7 +99,7 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function toggleDropdown(toggle) {
|
||||
let dropdown = document.getElementById(toggle.id + "-menu");
|
||||
const dropdown = document.getElementById(toggle.id + "-menu");
|
||||
if (dropdown.style.maxHeight == "0px" || dropdown.style.maxHeight == "") {
|
||||
dropdown.style.maxHeight = dropdown.scrollHeight + "px";
|
||||
toggle.style.borderRadius = "10px 10px 0 0";
|
||||
|
|
@ -120,12 +120,12 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function closeOtherDropdowns(dropdownIDToExclude) {
|
||||
let dropdowns = document.getElementsByClassName("dropdown-menu");
|
||||
const dropdowns = document.getElementsByClassName("dropdown-menu");
|
||||
Array.from(dropdowns).forEach((dropdown) => {
|
||||
dropdown.style.maxHeight = "0px";
|
||||
setTimeout(() => {
|
||||
if (dropdown.id != dropdownIDToExclude + "-menu") {
|
||||
let dropdown_toggle = document.getElementById(dropdown.id.replace("-menu", ""));
|
||||
const dropdown_toggle = document.getElementById(dropdown.id.replace("-menu", ""));
|
||||
dropdown_toggle.style.borderRadius = "10px";
|
||||
}
|
||||
}, 300);
|
||||
|
|
@ -133,11 +133,11 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function closeDropdown(dropdownID) {
|
||||
let dropdown = document.getElementById(dropdownID);
|
||||
const dropdown = document.getElementById(dropdownID);
|
||||
if (dropdown) {
|
||||
dropdown.style.maxHeight = "0px";
|
||||
setTimeout(() => {
|
||||
let dropdown_toggle = document.getElementById(dropdownID.replace("-menu", ""));
|
||||
const dropdown_toggle = document.getElementById(dropdownID.replace("-menu", ""));
|
||||
dropdown_toggle.style.borderRadius = "10px";
|
||||
}, 300);
|
||||
}
|
||||
|
|
@ -145,14 +145,14 @@ export function getStaticPaths() {
|
|||
|
||||
function getLocalStorageValue(localStorageItem, dropdownID) {
|
||||
// I was kinda dumb for not doing this earlier.
|
||||
let dropdown = document.getElementById(dropdownID);
|
||||
let dropdownMenu = document.getElementById(dropdownID + "-menu");
|
||||
const dropdown = document.getElementById(dropdownID);
|
||||
const dropdownMenu = document.getElementById(dropdownID + "-menu");
|
||||
|
||||
if (dropdown && dropdownMenu) {
|
||||
// Now we find the child that matches localStorageItem.value.
|
||||
let dropdownItem = Array.from(dropdownMenu.children).find((item) => {
|
||||
return JSON.parse(localStorage.getItem(localStorageItem)).value == item.dataset.setting;
|
||||
});
|
||||
const dropdownItem = Array.from(dropdownMenu.children).find((item) => {
|
||||
return JSON.parse(localStorage.getItem(localStorageItem)).value == item.dataset.setting;
|
||||
});
|
||||
// Now set the inner text to the name in the dropdownItem.
|
||||
return dropdownItem.innerText;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ export function getStaticPaths() {
|
|||
|
||||
function applySavedLocalStorage(localStorageItem, dropdownID) {
|
||||
if (localStorage.getItem(localStorageItem)) {
|
||||
let dropdown_toggle = document.getElementById(dropdownID);
|
||||
const dropdown_toggle = document.getElementById(dropdownID);
|
||||
if (dropdown_toggle) {
|
||||
dropdown_toggle.innerText = getLocalStorageValue(localStorageItem, dropdownID);
|
||||
}
|
||||
|
|
@ -168,14 +168,14 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function applyDropdownEventListeners(dropdown, optionalCallback) {
|
||||
let dropdownSibling = document.getElementById(dropdown.id + "-menu");
|
||||
let localStorageItem = dropdown.dataset.localStorageKey;
|
||||
const dropdownSibling = document.getElementById(dropdown.id + "-menu");
|
||||
const localStorageItem = dropdown.dataset.localStorageKey;
|
||||
Array.from(dropdownSibling.children).forEach((child) => {
|
||||
child.onclick = () => {
|
||||
let localStorageItemContent = {
|
||||
name: child.innerText,
|
||||
value: child.dataset.setting,
|
||||
};
|
||||
const localStorageItemContent = {
|
||||
name: child.innerText,
|
||||
value: child.dataset.setting,
|
||||
};
|
||||
localStorage.setItem(localStorageItem, JSON.stringify(localStorageItemContent));
|
||||
applySavedLocalStorage(localStorageItem, dropdown.id);
|
||||
closeDropdown(dropdownSibling.id);
|
||||
|
|
@ -194,15 +194,15 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function addThemeToDropdown(extension) {
|
||||
let dropdown = document.getElementById("dropdown__selected-theme-menu");
|
||||
const dropdown = document.getElementById("dropdown__selected-theme-menu");
|
||||
if (dropdown) {
|
||||
// TODO: Figure out why addThemeToDropdown is being called 6 times
|
||||
// This when you go from another page and back to settings->customization.
|
||||
let duplicateItem = Array.from(dropdown.children).find((item) => {
|
||||
return item.dataset.setting == extension.themeName;
|
||||
});
|
||||
const duplicateItem = Array.from(dropdown.children).find((item) => {
|
||||
return item.dataset.setting == extension.themeName;
|
||||
});
|
||||
if (duplicateItem) return;
|
||||
let themeItem = document.createElement("li");
|
||||
const themeItem = document.createElement("li");
|
||||
themeItem.classList.add("dropdown-item");
|
||||
themeItem.dataset.setting = extension.themeName;
|
||||
themeItem.textContent = extension.title;
|
||||
|
|
@ -215,7 +215,7 @@ export function getStaticPaths() {
|
|||
loadContent("setting-tab-proxy");
|
||||
|
||||
function setupCustomizationSettings() {
|
||||
let store = window.idb.transaction("InstalledExtensions", "readonly").objectStore("InstalledExtensions");
|
||||
const store = window.idb.transaction("InstalledExtensions", "readonly").objectStore("InstalledExtensions");
|
||||
store.getAll().onsuccess = (event) => {
|
||||
const result = event.target.result;
|
||||
if (result) {
|
||||
|
|
@ -229,8 +229,8 @@ export function getStaticPaths() {
|
|||
applySavedLocalStorage("alu__selectedTheme", "dropdown__selected-theme");
|
||||
applySavedLocalStorage("alu__selectedLanguage", "dropdown__selected-language");
|
||||
|
||||
let themeDropdown = document.getElementById("dropdown__selected-theme");
|
||||
let languageDropdown = document.getElementById("dropdown__selected-language");
|
||||
const themeDropdown = document.getElementById("dropdown__selected-theme");
|
||||
const languageDropdown = document.getElementById("dropdown__selected-language");
|
||||
applyDropdownEventListeners(themeDropdown, changeTheme);
|
||||
applyDropdownEventListeners(languageDropdown, navigateToNewLangaugePage);
|
||||
};
|
||||
|
|
@ -242,11 +242,11 @@ export function getStaticPaths() {
|
|||
let cloakName = cloak.dataset.cloakName;
|
||||
let cloakIcon = cloak.dataset.cloakIcon;
|
||||
|
||||
let localStorageItem = {
|
||||
name: cloakName,
|
||||
icon: cloakIcon,
|
||||
isCustom: false,
|
||||
};
|
||||
const localStorageItem = {
|
||||
name: cloakName,
|
||||
icon: cloakIcon,
|
||||
isCustom: false,
|
||||
};
|
||||
localStorage.setItem("alu__selectedCloak", JSON.stringify(localStorageItem));
|
||||
|
||||
if (cloakName == "None") {
|
||||
|
|
@ -272,10 +272,10 @@ export function getStaticPaths() {
|
|||
});
|
||||
});
|
||||
|
||||
let customNameInput = document.getElementById("cloak-custom-name-input");
|
||||
let customFaviconInput = document.getElementById("cloak-custom-favicon-input");
|
||||
const customNameInput = document.getElementById("cloak-custom-name-input");
|
||||
const customFaviconInput = document.getElementById("cloak-custom-favicon-input");
|
||||
if (localStorage.getItem("alu__selectedCloak")) {
|
||||
let selectedCloak = JSON.parse(localStorage.getItem("alu__selectedCloak"));
|
||||
const selectedCloak = JSON.parse(localStorage.getItem("alu__selectedCloak"));
|
||||
if (selectedCloak.isCustom) {
|
||||
customNameInput.value = selectedCloak.name;
|
||||
customFaviconInput.value = selectedCloak.icon;
|
||||
|
|
@ -285,11 +285,11 @@ export function getStaticPaths() {
|
|||
document.getElementById("cloak-custom-button").addEventListener("click", () => {
|
||||
let cloakName = document.getElementById("cloak-custom-name-input").value;
|
||||
let cloakIcon = document.getElementById("cloak-custom-favicon-input").value;
|
||||
let localStorageItem = {
|
||||
name: cloakName,
|
||||
icon: cloakIcon,
|
||||
isCustom: true,
|
||||
};
|
||||
const localStorageItem = {
|
||||
name: cloakName,
|
||||
icon: cloakIcon,
|
||||
isCustom: true,
|
||||
};
|
||||
localStorage.setItem("alu__selectedCloak", JSON.stringify(localStorageItem));
|
||||
if (cloakName == "None") {
|
||||
localStorage.removeItem("alu__selectedCloak");
|
||||
|
|
@ -308,10 +308,10 @@ export function getStaticPaths() {
|
|||
}
|
||||
|
||||
function changeTheme() {
|
||||
let theme = JSON.parse(localStorage.getItem("alu__selectedTheme")).value;
|
||||
const theme = JSON.parse(localStorage.getItem("alu__selectedTheme")).value;
|
||||
if (theme) {
|
||||
document.documentElement.setAttribute("data-theme", theme.toLowerCase());
|
||||
let footer = document.getElementById("footer");
|
||||
const footer = document.getElementById("footer");
|
||||
if (footer) {
|
||||
footer.dataset.theme = theme.toLowerCase();
|
||||
}
|
||||
|
|
@ -325,16 +325,16 @@ export function getStaticPaths() {
|
|||
applySavedLocalStorage("alu__selectedOpenWith", "dropdown__open-with");
|
||||
applySavedLocalStorage("alu__selectedTransport", "dropdown__transport");
|
||||
// Dropdowns
|
||||
let selectedProxyDropdown = document.getElementById("dropdown__selected-proxy");
|
||||
let searchEngineDropdown = document.getElementById("dropdown__search-engine");
|
||||
let openWithDropdown = document.getElementById("dropdown__open-with");
|
||||
let currentTransportDropdown = document.getElementById("dropdown__transport");
|
||||
let wispURLDropdown = document.getElementById("dropdown__wisp-url");
|
||||
const selectedProxyDropdown = document.getElementById("dropdown__selected-proxy");
|
||||
const searchEngineDropdown = document.getElementById("dropdown__search-engine");
|
||||
const openWithDropdown = document.getElementById("dropdown__open-with");
|
||||
const currentTransportDropdown = document.getElementById("dropdown__transport");
|
||||
const wispURLDropdown = document.getElementById("dropdown__wisp-url");
|
||||
|
||||
// Inputs
|
||||
let searxngUrlInput = document.getElementById("searxng-url-input");
|
||||
let bareURLInput = document.getElementById("bare-url-input");
|
||||
let savedSearxngUrl = localStorage.getItem("alu__searxngUrl");
|
||||
const searxngUrlInput = document.getElementById("searxng-url-input");
|
||||
const bareURLInput = document.getElementById("bare-url-input");
|
||||
const savedSearxngUrl = localStorage.getItem("alu__searxngUrl");
|
||||
if (savedSearxngUrl != null) {
|
||||
if (savedSearxngUrl == "") localStorage.setItem("alu__searxngUrl", "https://searxng.site/");
|
||||
searxngUrlInput.value = localStorage.getItem("alu__searxngUrl");
|
||||
|
|
@ -343,7 +343,7 @@ export function getStaticPaths() {
|
|||
// const webSocketProtocol = useWss ? "wss://" : "ws://";
|
||||
// let savedWispUrl = localStorage.getItem("alu__wispUrl");
|
||||
// if (savedWispUrl == null || savedWispUrl == "") localStorage.setItem("alu__wispUrl", webSocketProtocol + location.host + "/wisp/");
|
||||
let savedBareUrl = localStorage.getItem("alu__bareUrl");
|
||||
const savedBareUrl = localStorage.getItem("alu__bareUrl");
|
||||
if (savedBareUrl == null || savedBareUrl == "") localStorage.setItem("alu__bareUrl", location.origin + "/bare/");
|
||||
|
||||
bareURLInput.value = localStorage.getItem("alu__bareUrl");
|
||||
|
|
@ -365,7 +365,7 @@ export function getStaticPaths() {
|
|||
|
||||
function checkSearxng() {
|
||||
// This function checks if the "searxng" option was clicked, display an additional option if so.
|
||||
let search_engine = JSON.parse(localStorage.getItem("alu__search_engine"));
|
||||
const search_engine = JSON.parse(localStorage.getItem("alu__search_engine"));
|
||||
if (search_engine) {
|
||||
if (search_engine.value.toLowerCase() == "searx") {
|
||||
document.getElementsByClassName("setting__searxng-url")[0].style.opacity = "1";
|
||||
|
|
@ -378,12 +378,12 @@ export function getStaticPaths() {
|
|||
document.addEventListener("setting-tabLoad", setupSettings);
|
||||
|
||||
function navigateToNewLangaugePage() {
|
||||
let value = JSON.parse(localStorage.getItem("alu__selectedLanguage")).value;
|
||||
let currentLanguage = window.location.pathname.split("/")[1];
|
||||
const value = JSON.parse(localStorage.getItem("alu__selectedLanguage")).value;
|
||||
const currentLanguage = window.location.pathname.split("/")[1];
|
||||
// Do nothing.. because we're already on the page.
|
||||
if (value == currentLanguage) return;
|
||||
window.location.href = `/${value}/settings`;
|
||||
}
|
||||
window.location.href = `/${value}/settings`;
|
||||
}
|
||||
}
|
||||
document.addEventListener("astro:after-swap", () => {
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ export const prerender = false;
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
import games from "../../json/games.json";
|
||||
|
||||
let gamesList = games as GameList;
|
||||
const gamesList = games as GameList;
|
||||
|
||||
// get the current game based on the information in the url
|
||||
let game = Astro.params.game;
|
||||
const game = Astro.params.game;
|
||||
if (!game) {
|
||||
Astro.redirect("/en/games/");
|
||||
return;
|
||||
|
|
@ -16,7 +16,7 @@ function isValidGameKey(key: string) {
|
|||
return key in gamesList;
|
||||
}
|
||||
|
||||
let gameData = isValidGameKey(game) ? gamesList[game] : null;
|
||||
const gameData = isValidGameKey(game) ? gamesList[game] : null;
|
||||
|
||||
if (!gameData) {
|
||||
return Astro.redirect("/en/games/");
|
||||
|
|
@ -95,7 +95,7 @@ if (!gameData) {
|
|||
</style>
|
||||
|
||||
<script>
|
||||
let iframe = document.getElementById("game-frame") as HTMLIFrameElement;
|
||||
const iframe = document.getElementById("game-frame") as HTMLIFrameElement;
|
||||
iframe.contentWindow?.focus();
|
||||
|
||||
iframe?.addEventListener("load", () => {
|
||||
|
|
@ -107,11 +107,11 @@ if (!gameData) {
|
|||
});
|
||||
|
||||
document.addEventListener("astro:after-swap", () => {
|
||||
let iframe = document.getElementById("game-frame") as HTMLIFrameElement;
|
||||
const iframe = document.getElementById("game-frame") as HTMLIFrameElement;
|
||||
iframe?.contentWindow?.focus();
|
||||
});
|
||||
|
||||
let fullscreen = document.getElementById("game-fullscreen") as HTMLImageElement;
|
||||
const fullscreen = document.getElementById("game-fullscreen") as HTMLImageElement;
|
||||
|
||||
fullscreen.addEventListener("click", () => {
|
||||
if (iframe.requestFullscreen) {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ import { ViewTransitions } from "astro:transitions";
|
|||
<meta property="twitter:image" content="/logo.png" />
|
||||
<ViewTransitions />
|
||||
<script>
|
||||
let currentLang = localStorage.getItem("alu__selectedLanguage");
|
||||
const currentLang = localStorage.getItem("alu__selectedLanguage");
|
||||
const redirect = (loc: string) => (window.location.href = loc);
|
||||
if (currentLang) {
|
||||
try {
|
||||
let parsed = JSON.parse(currentLang).value;
|
||||
const parsed = JSON.parse(currentLang).value;
|
||||
redirect(`/${parsed}/`);
|
||||
} catch {
|
||||
localStorage.clear();
|
||||
|
|
|
|||
5
src/types.d.ts
vendored
5
src/types.d.ts
vendored
|
|
@ -5,11 +5,8 @@ interface Window {
|
|||
decodeUrl: (url: string) => string;
|
||||
};
|
||||
__uv$location: Location;
|
||||
loadFormContent: Function | null;
|
||||
loadSelectedTransport: Function | null;
|
||||
loadedThemeAtob: string;
|
||||
loadFormContent: () => Promise<void> | null;
|
||||
idb: IDBDatabase;
|
||||
URLPattern: URLPattern | null;
|
||||
// Why is this not already on Window?
|
||||
eval(string): void;
|
||||
wispData: WispData[];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue