Skip to content

added go to discord button #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/discord-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,26 @@ footer a:hover {
border-radius: 6px;
}

#uv-gotodiscord {
background-color: #3e3e3e;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}

#uv-gotodiscord:hover {
background-color: #4f4f4f;
}

#uv-gotodiscord img {
width: 1.5em;
height: 1.5em;
vertical-align: middle;
margin-right: 5px;
}

.credit {
border-radius: 10px;
padding: 10px;
Expand Down Expand Up @@ -181,4 +201,4 @@ footer a:hover {

.credit input:checked ~ pre {
display: block;
}
}
4 changes: 4 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ <h1>Ultraviolet | TN</h1>
/>
<input id="uv-address" type="text" placeholder="Search the web freely" />
</form>
<button id="uv-gotodiscord" class="flex-center">
<img src="discord-icon.png" alt="Discord" />
<span>Just go to Discord</span>
</button>
<div class="desc left-margin">
<p id="uv-error"></p>
<pre id="uv-error-code"></pre>
Expand Down
25 changes: 25 additions & 0 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* @type {HTMLFormElement}
*/
const form = document.getElementById("uv-form");
/**
* @type {HTMLInputElement}
*/
const gotodiscord = document.getElementById("uv-gotodiscord");
/**
* @type {HTMLInputElement}
*/
Expand Down Expand Up @@ -42,3 +46,24 @@ form.addEventListener("submit", async (event) => {
}
frame.src = __uv$config.prefix + __uv$config.encodeUrl(url);
});
gotodiscord.addEventListener("click", 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);

let frame = document.getElementById("uv-frame");
frame.style.display = "block";
let wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/";
if (await connection.getTransport() !== "/epoxy/index.mjs") {
await connection.setTransport("/epoxy/index.mjs", [{ wisp: wispUrl }]);
}
frame.src = __uv$config.prefix + __uv$config.encodeUrl("https://discord.com/login");
});