Skip to content

Commit

Permalink
stativc
Browse files Browse the repository at this point in the history
  • Loading branch information
bachwebsite committed Apr 5, 2024
1 parent c47081e commit 5f8348f
Show file tree
Hide file tree
Showing 9 changed files with 1,101 additions and 0 deletions.
18 changes: 18 additions & 0 deletions static/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";
const error = document.getElementById("uv-error");
const errorCode = document.getElementById("uv-error-code");
const registerButton = document.getElementById("register-proxy");
const page = window.location.pathname

if (registerButton) {
registerButton.addEventListener("click", async () => {
try {
await registerSW();
location.reload();
} catch (err) {
error.textContent = "Failed to register service worker.";
errorCode.textContent = err.toString();
registerButton.classList.remove("show");
}
});
};
180 changes: 180 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/png" href="https://github.com/GalacticNetwork/jordansmathwork-v5/raw/main/assets/images/jmw.png?raw=true">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<style>
/* Custom CSS for black theme */
body {
background-color: #262626;
color: white;
margin: 0;
padding: 0;
}

#header {
background-color: #222;
padding: 20px;
text-align: center;
}

#header h1 {
margin: 0;
font-size: 24px;
font-family: 'Quicksand', sans-serif;
color: #fff;
letter-spacing: 2px;
text-transform: uppercase;
}

#header img {
width: 20%;
height: auto;
}

#content {
text-align: center;
padding: 20px;
margin-top: -4%;
}

#content h1 {
font-size: 24px;
cursor:pointer;
text-transform: uppercase;
font-family: 'Quicksand', sans-serif;
line-height: 1.5;
margin-bottom: 20px;
}

#searchbar {
text-align: center;
margin: 20px auto;
font-family: 'Quicksand', sans-serif;
}

.form__input {
padding: 15px;
margin-bottom: 20px;
width: calc(50% - 30px);
border: none;
border-radius: 15px;
background-color: #101010;
color: white;
box-shadow: 0 0 10px white;
transition: 1s;
text-align:center;
font-family: 'Quicksand', sans-serif;
}

a{
text-decoration: none;
color:white;
width:50px;
height:50px;
padding-right: 1px;
padding-left: 1px;
text-align: center;
align-self: center;
}

.form__input::placeholder {
color: #aaa;
text-align: center;
}

.form__input:focus {
outline: none;
background-color: black;
text-align:center;
width: 700px;
}
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@700&display=swap');
#footer {
position: fixed;
left: 0;
bottom: 0;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #99ccff;
font-family: 'Quicksand', sans-serif;
width: 100%;
height:15px;
background-color: #000;
padding-top: 7.5px;
padding-bottom: 10px;
text-align: center;
color: #fff;
font-size: 14px;
}

#footer p {
margin: 0;
}

.fa {
font-size: 24px;
margin-right: 10px;
color: #fff;
}

.fa:hover {
color: #aaa;
}
#uv-error {
color: #ff6666 !important;
white-space: pre-wrap;
}

#uv-error-code {
font-size: 12px;
color: #fff;
font-family: "Courier New", Courier, monospace;
}

#uv-register-sw {
color: white;
background: #555555;
cursor: pointer;
outline: none;
border: none;
border-radius: 6px;
padding: 16px 20px;
line-height: 16px;
display: none;
}

#uv-register-sw:active {
background: #333333;
}

#uv-register-sw.show {
display: block;
}
</style>
</head>
<body>
<div id="header">
<img src="https://github.com/GalacticNetwork/jordansmathwork-v5/raw/main/assets/images/jmw.png?raw=true" alt="Logo">
</div>
<div id="content">
<h1>Jordan's Math Work | Unblocker</h1>

<form id="uv-form"">
<input id="uv-search-engine" value="https://www.google.com/search?q=%s" type="hidden"/>
<input id="uv-address" type="text" placeholder="Search Google or type an URL" class="form__input"/>
</form>
<div class="desc left-margin">
<p id="uv-error"></p>
<pre id="uv-error-code"></pre>
</div>
</div>
<script src="/static/uv/uv.bundle.js" defer></script>
<script src="/static/uv/uv.config.js" defer></script>
<script src="/static/register-sw.js" defer></script>
<script src="/static/search.js" defer></script>
<script src="/static/index.js" defer></script>
<script src="/static/error.js" defer></script>
</body>
</html>
36 changes: 36 additions & 0 deletions static/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";
/**
* @type {HTMLFormElement}
*/
const form = document.getElementById("uv-form");
/**
* @type {HTMLInputElement}
*/
const address = document.getElementById("uv-address");
/**
* @type {HTMLInputElement}
*/
const searchEngine = document.getElementById("uv-search-engine");
/**
* @type {HTMLParagraphElement}
*/
const error = document.getElementById("uv-error");
/**
* @type {HTMLPreElement}
*/
const errorCode = document.getElementById("uv-error-code");

form.addEventListener("submit", async (event) => {
event.preventDefault();

try {
await registerSW();
} catch (err) {
error.textContent = "Failed to register service worker.";
errorCode.textContent = err.toString();
throw err;
}

const url = search(address.value, searchEngine.value);
location.href = __uv$config.prefix + __uv$config.encodeUrl(url);
});
30 changes: 30 additions & 0 deletions static/register-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";
/**
* Distributed with Ultraviolet and compatible with most configurations.
*/
const stockSW = "/static/uv-sw.js";

/**
* List of hostnames that are allowed to run serviceworkers on http:
*/
const swAllowedHostnames = ["localhost", "127.0.0.1"];

/**
* Global util
* Used in 404.html and index.html
*/
async function registerSW() {
if (
location.protocol !== "https:" &&
!swAllowedHostnames.includes(location.hostname)
)
throw new Error("Service workers cannot be registered without https.");

if (!navigator.serviceWorker)
throw new Error("Your browser doesn't support service workers.");

// Ultraviolet has a stock `sw.js` script.
await navigator.serviceWorker.register(stockSW, {
scope: __uv$config.prefix,
});
}
32 changes: 32 additions & 0 deletions static/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
/**
*
* @param {string} input
* @param {string} template Template for a search query.
* @returns {string} Fully qualified URL
*/
function search(input, template) {
try {
// input is a valid URL:
// eg: https://example.com, https://example.com/test?q=param
return new URL(input).toString();
} catch (err) {
// input was not a valid URL
}

try {
// input is a valid URL when http:// is added to the start:
// eg: example.com, https://example.com/test?q=param
const url = new URL(`http://${input}`);
// only if the hostname has a TLD/subdomain
if (url.hostname.includes(".")) return url.toString();
} catch (err) {
// input was not valid URL
}

// input may have been a valid URL, however the hostname was invalid

// Attempts to convert the input to a fully qualified URL have failed
// Treat the input as a search query
return template.replace("%s", encodeURIComponent(input));
}
5 changes: 5 additions & 0 deletions static/uv-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
importScripts("/static/uv/uv.sw.js");

const sw = new UVServiceWorker();

self.addEventListener("fetch", (event) => event.respondWith(sw.fetch(event)));
1 change: 1 addition & 0 deletions static/uv/uv.bundle.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions static/uv/uv.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
self.__uv$config = {
prefix: '/static/jmwsw/',
bare:'https://math-english-sci.vercel.app',
encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode,
handler: '/static/uv/uv.handler.js',
bundle: '/static/uv/uv.bundle.js',
config: '/static/uv/uv.config.js',
sw: '/static/uv/uv.sw.js',
};
Loading

0 comments on commit 5f8348f

Please sign in to comment.