Skip to content

Commit

Permalink
Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
NCCoder1 committed Jun 6, 2023
1 parent fbdf835 commit 3a470e2
Show file tree
Hide file tree
Showing 17 changed files with 2,326 additions and 1 deletion.
1 change: 0 additions & 1 deletion asd

This file was deleted.

39 changes: 39 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# TIW Static UV

Modified Version of the <a href="https://github.com/titaniumnetwork-dev/Ultraviolet-App" target="blank">Ultraviolet</a> backend. This modification makes the proxy a static website, something no one has ever done before.
<br> <strong> Our Developers That Worked on This Project: </strong>
NC Gaming#0058 and Kwazehhh#7245 <center> Join our discord <a href="https://discord.gg/zJhPJYJCeJ" target="_blank" style="text-decoration:none;"> here </a><br>
<a> <img src="logo.gif" style="width:25%; align-self:center;"> </img> </a>
</center> <br>

## Features

- Search the web using the FIRST static proxy.
- Access to any website
- Deployable on any static hosting platform
<br><br>

## Deployment

To deploy this website locally, follow these steps:

1. Clone the repository: `git clone https://github.com/TheTIW/UV-Static`
2. Navigate to the project directory: `cd UV-Static`
3. Open the index.html file in a web browser (Cannot be run locally).
<br><br>

## Hosting

You can host this on any static hosting platoform. <br>
[![Remix on Glitch](https://binbashbanana.github.io/deploy-buttons/buttons/remade/glitch.svg)](https://glitch.com/edit/#!/import/github/TheTIW/UV-Static)
[![Run on Google Cloud](https://binbashbanana.github.io/deploy-buttons/buttons/remade/googlecloud.svg)](https://deploy.cloud.run/?git_repo=https://github.com/TheTIW/UV-Static)
[![Deploy with Vercel](https://binbashbanana.github.io/deploy-buttons/buttons/remade/vercel.svg)](https://vercel.com/new/clone?repository-url=https://github.com/TheTIW/UV-Static)
[![Deploy with Netlify](https://binbashbanana.github.io/deploy-buttons/buttons/remade/netlify.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/TheTIW/UV-Static)
[![Deploy to Render](https://binbashbanana.github.io/deploy-buttons/buttons/remade/render.svg)](https://render.com/deploy?repo=https://github.com/TheTIW/UV-Static)
## Contributing

Contributions are welcome! If you have any suggestions or improvements, please create a pull request.
<br><br>
## License

This project is licensed under the [MIT License](LICENSE).
51 changes: 51 additions & 0 deletions static/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, shrink-to-fit=no"
/>
<title>Ultraviolet | Error</title>
<meta
name="description"
content="Ultraviolet is a highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers. Unblock sites today!"
/>
<meta
name="theme-color"
media="(prefers-color-scheme: dark)"
content="#434c5e"
/>
<meta name="googlebot" content="noindex, nofollow, nosnippet" />
<base href="/" />
<link rel="shortcut icon" content="favicon.ico" />
<link rel="stylesheet" href="index.css" />
</head>

<body>
<div class="logo-wrapper left-margin">
<h1>Ultraviolet | Error</h1>
</div>
<div class="desc left-margin">
<p>The server could not route your request.</p>
<p id="uv-error"></p>
<code id="uv-error-code"></code>
<button id="uv-register-sw" value="Register service worker">
Register ServiceWorker
</button>
</div>
<footer>
<a
title="License information"
href="credits.html"
style="margin-left: auto"
>Credits</a
>
<span>Ultraviolet &copy; TN 2022</span>
</footer>
<script src="uv/uv.bundle.js"></script>
<script src="uv/uv.config.js"></script>
<script src="register-sw.js"></script>
<script src="error.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions static/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use strict";
const error = document.getElementById("uv-error");
const errorCode = document.getElementById("uv-error-code");
const registerButton = document.getElementById("uv-register-sw");

if (location.pathname.startsWith(__uv$config.prefix)) {
error.textContent = "Error: The service worker is not registered.";
registerButton.classList.add("show");
}

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");
}
});
117 changes: 117 additions & 0 deletions static/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* Custom CSS for black theme */
body {
background-color: #000;
color: #fff;
margin: 0;
padding: 0;
}

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

#header h1 {
margin: 0;
font-size: 24px;
font-family: 'Arial', 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: 'Open Sans', sans-serif;
line-height: 1.5;
margin-bottom: 20px;
}

#searchbar {
text-align: center;
margin: 20px auto;
}

.form__input {
padding: 10px;
border: none;
border-radius: 5px;
font-size: 16px;
width: 300px;
box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
background-color: #222;
text-align: center;
color: #fff;
cursor:cell;
}

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:hover{
cursor:cell;
}

.form__input:focus {
outline: none;
box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
#footer {
position: fixed;
left: 0;
bottom: 0;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #99ccff;
font-family: 'Open Sans', 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;
}
39 changes: 39 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Oswald&display=swap" rel="stylesheet">
</head>
<body>
<div id="header">
<img src="logo.gif" alt="Logo">
</div>
<div id="content">
<h1>Search the Web and use the FIRST static proxy</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>
<a href="https://discord.gg/zJhPJYJCeJ" target="_blank" class="fa-brands fa-discord"></a>
<a href="https://github.com/TheTIW/UV-Static" target="_blank"class="fa-brands fa-github"></a>
<a href="https://starttiw.org" target="_blank"class="fa-solid fa-cloud"></a>
</div>
<script src="uv/uv.bundle.js" defer></script>
<script src="uv/uv.config.js" defer></script>
<script src="register-sw.js" defer></script>
<script src="search.js" defer></script>
<script src="index.js" defer></script>
<div id="footer">
<p>&copy; 2023 TIW. All rights reserved.</p>
</div>
</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);
});
Binary file added static/logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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));
}
21 changes: 21 additions & 0 deletions static/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var cacheName = 'TIWcog';
var filesToCache = [
'/js/sw.js'
];

self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(cacheName).then(function(cache) {
return cache.addAll(filesToCache);
})
);
self.skipWaiting();
});

self.addEventListener('fetch', function(e) {
e.respondWith(
caches.match(e.request).then(function(response) {
return response || fetch(e.request);
})
);
});
Loading

0 comments on commit 3a470e2

Please sign in to comment.