cloak presets

This commit is contained in:
Sky 2023-09-16 15:27:32 -04:00
parent a775d35394
commit 52b516e5af
6 changed files with 90 additions and 34 deletions

17
cloaks.json Normal file
View File

@ -0,0 +1,17 @@
{
"google": [
"Google", "https://google.com/favicon.ico"
],
"canvas": [
"Dashboard", "https://du11hjcvx0uqb.cloudfront.net/dist/images/favicon-e10d657a73.ico"
],
"desmos": [
"Desmos | Graphing Calculator", "https://www.desmos.com/assets/img/apps/graphing/favicon.ico"
],
"drive": [
"My Drive - Google Drive", "https://ssl.gstatic.com/docs/doclist/images/drive_2022q3_32dp.png"
],
"classroom": [
"Home", "https://ssl.gstatic.com/classroom/ic_product_classroom_144.png"
]
}

View File

@ -1,3 +0,0 @@
export function onRequest(context) {
return new Response("Hello, world!")
}

48
js/cloaks.js Normal file
View File

@ -0,0 +1,48 @@
let cloaklist;
$.getJSON("/cloaks.json", function (data) {
cloaklist = data;
});
function cloakExceptions(url) {
if (url.includes("harrisonburg.instructure.com") == true) {
return "learn.canvas.net";
}
return url;
}
function setCloakCookie(name, url) {
console.log(name + url);
if (!(url == null)) {
document.cookie =
"tabicon=" + url;
document.cookie = "tabname=" + name;
setCloak();
} else {
url = cloakExceptions($("#webicon").val());
document.cookie =
"tabicon=https://s2.googleusercontent.com/s2/favicons?domain_url=" + url;
document.cookie = "tabname=" + $("#webname").val();
setCloak();
}
}
function clearCloak() {
document.cookie = "tabicon=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
document.cookie = "tabname=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
var link = document.querySelector("link[rel~='icon']");
link.remove();
document.title = "Tab Cloak | e-gamepass";
link = document.createElement("link");
link.rel = "icon";
document.head.appendChild(link);
link.href = "/favicon.png";
}
function loadCloaks() {
var presetCloaks = document.getElementById("presetCloaks");
presetCloaks.onchange = (event) => {
setCloakCookie(
cloaklist[event.target.value][0],
cloaklist[event.target.value][1]
);
};
}

View File

@ -19,6 +19,7 @@ window.onload = function () {
} else {
document.body.setAttribute("theme", "main")
}
loadCloaks();
checkAlert();
check();
};
@ -85,28 +86,4 @@ function setPanicMode() {
return;
}
document.cookie = "panicurl=" + $("#panic").val();
}
function cloakExceptions(url) {
if (url.includes('harrisonburg.instructure.com') == true) {
return "learn.canvas.net";
}
return url;
}
function setCloakCookie() {
url = cloakExceptions($('#webicon').val())
document.cookie = 'tabicon=https://s2.googleusercontent.com/s2/favicons?domain_url=' + url;
document.cookie = 'tabname=' + $('#webname').val();
setCloak();
}
function clearCloak() {
document.cookie = "tabicon=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
document.cookie = "tabname=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
var link = document.querySelector("link[rel~='icon']");link.remove();
document.title = "Tab Cloak | e-gamepass";
link = document.createElement('link');
link.rel = 'icon';
document.head.appendChild(link);
link.href = "/favicon.png";
}

View File

@ -13,6 +13,7 @@
<script src="/js/themes.js"></script>
<script src="/js/all.js"></script>
<script src="/js/main.js"></script>
<script src="/js/cloaks.js"></script>
<link rel="stylesheet" href="/themes.css" />
<link rel="stylesheet" href="/style.css" />
@ -53,12 +54,18 @@
<main>
<h1>Settings</h1>
<form action="javascript:setCloakCookie();">
<h3 for="webname">Website Name</h3>
<br />
<h3>Website Name</h3>
<input type="text" id="webname" name="webname" placeholder="Selenite" /><br />
<h3 for="webicon">Website Icon</h3>
<br />
<input type="text" id="webicon" name="webicon" placeholder="https://selenite.pages.dev/" /><br /><br />
<h3>Website Icon</h3>
<input type="text" id="webicon" name="webicon" placeholder="https://selenite.pages.dev/" /><br />
<h3>Or select a preset:</h3>
<select id="presetCloaks">
<option value="google">Google</option>
<option value="canvas">Canvas</option>
<option value="desmos">Desmos</option>
<option value="drive">Google Drive</option>
<option value="classroom">Google Classroom</option>
</select><br />
<input id="websubmit" class="submit" type="submit" value="Set Tab Cloak" />
</form>
<button onclick="javascript:clearCloak();">Clear your current tab cloak</button>
@ -74,7 +81,6 @@
<br />
<form action="javascript:setPanicMode();">
<h3 for="panic">Website URL</h3>
<br />
<input type="text" id="panic" name="panic" placeholder="https://google.com" /><br />
<input id="panic" class="submit" type="submit" value="Set Panic Mode" />
</form>

View File

@ -113,7 +113,7 @@ button, input#websubmit.submit, input[type=submit]#panic {
border-width: 5px;
border-radius: 10px;
border-style: solid;
padding: 10px;
padding: 7px;
margin-left: 20px;
margin-right: 20px;
margin: 10px;
@ -237,4 +237,15 @@ form {
}
.samerow.themebtns {
width: 70%;
}
select {
border-radius: 5px;
background-color: var(--inputbg);
border-color: var(--inputborder);
border-width: 5px;
border-radius: 10px;
border-style: solid;
padding: 0.5% 0.5%;
margin: 0.25%;
}