From 884405dd1a159024ef0c7ba3a3e5e3b84c48fe65 Mon Sep 17 00:00:00 2001 From: BinBashBanana <51469593+BinBashBanana@users.noreply.github.com> Date: Tue, 1 Nov 2022 17:46:23 -0700 Subject: [PATCH] Better errors for Ultraviolet-Node --- public/error.html | 52 +++++++++++++++++++++++++++++++++++++++++ public/error.js | 39 +++++++++++++++++++++++++++++++ public/index.css | 46 ++++++++++++++++++++++++++---------- public/index.html | 6 ++--- public/register-sw.html | 15 ++++++++++++ public/register-sw.js | 22 +++++++++++++++++ 6 files changed, 165 insertions(+), 15 deletions(-) create mode 100644 public/error.html create mode 100644 public/error.js create mode 100644 public/register-sw.html create mode 100644 public/register-sw.js diff --git a/public/error.html b/public/error.html new file mode 100644 index 0000000..2fa9a56 --- /dev/null +++ b/public/error.html @@ -0,0 +1,52 @@ + + + + + + Ultraviolet | Error + + + + + + + + + +
+

+ Ultraviolet | Error +

+
+
+

+ The server could not route your request. +

+

+ +
+ + + + + + + diff --git a/public/error.js b/public/error.js new file mode 100644 index 0000000..85754fd --- /dev/null +++ b/public/error.js @@ -0,0 +1,39 @@ +const errorContainer = document.querySelector(".error"); +const registerButton = document.querySelector(".register-sw"); +let registrarOpen = false; + +if (window.location.pathname.startsWith(__uv$config.prefix)) { + errorContainer.textContent += "The service worker is not registered. Click the button below to register the service worker."; + registerButton.style.display = "block"; +} + +function registrarResponse(response) { + if (response == "success") { + registerButton.style.display = "none"; + let span = document.createElement("span"); + span.className = "error-green"; + span.textContent = "\n\nSuccess. Reloading now..."; + errorContainer.appendChild(span); + window.location.reload(); + } + if (response == "failure") + errorContainer.textContent += "\n\nFailed to register service worker."; +} + +registerButton.onclick = () => { + if (!registrarOpen) { + registrarOpen = true; + let registrarFrame = document.createElement("iframe"); + registrarFrame.style.display = "none"; + registrarFrame.src = "./register-sw.html"; + document.body.appendChild(registrarFrame); + function messageHandler(event) { + window.removeEventListener("message", messageHandler); + registrarFrame.removeAttribute("src"); + document.body.removeChild(registrarFrame); + registrarOpen = false; + registrarResponse(event.data); + } + window.addEventListener("message", messageHandler); + } +} diff --git a/public/index.css b/public/index.css index 178f72f..e96969c 100644 --- a/public/index.css +++ b/public/index.css @@ -28,14 +28,46 @@ body { color: white; } -.logo-wrapper { +.flex-center { display: flex; - align-items: center; justify-content: center; +} + +.header-center { + align-items: center; flex-direction: column; margin-top: 10%; } +.left-margin { + margin: 0px 16px; +} + +.error { + color: #ff6666 !important; + white-space: pre-wrap; +} + +.error-green { + color: #66ff66 !important; +} + +.register-sw { + color: white; + background: #555555; + cursor: pointer; + outline: none; + border: none; + border-radius: 6px; + padding: 16px 20px; + line-height: 16px; + display: none; +} + +.register-sw:active { + background: #333333; +} + .logo { width: 150px; } @@ -76,16 +108,6 @@ footer a:hover { text-decoration: underline; } -form { - display: flex; - justify-content: center; -} - -.desc { - display: flex; - justify-content: center; -} - .desc p { width: 560px; color: rgba(253, 253, 253, 0.514); diff --git a/public/index.html b/public/index.html index 1aac809..ab42345 100644 --- a/public/index.html +++ b/public/index.html @@ -59,7 +59,7 @@ -
+

Ultraviolet is highly sophisticated proxy used for evading internet @@ -77,7 +77,7 @@

-
+