Skip to content

Commit

Permalink
Slightly cleaned up more JS code.
Browse files Browse the repository at this point in the history
  • Loading branch information
00Fjongl committed Jul 8, 2024
1 parent 876a26a commit 75b8703
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 45 deletions.
59 changes: 18 additions & 41 deletions views/assets/js/common-16451543478.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,43 @@
/* MAIN Holy Unblocker LTS Common Script
/* ----------------------------------------------- */

function tryGetElement(id) {
return document.getElementById(id) || {};
}
// Completely unused for some reason???
// const tryGetElement = id => document.getElementById(id) || {};

/**
* Get the preferred apex domain name.
* Not exactly apex, as any subdomain other than those listed will be ignored.
**/

function getDomain() {
return location.host.replace(/^(www|edu|cooking|beta)\./, "");
}
const getDomain = () => location.host.replace(/^(www|edu|cooking|beta)\./, "");

/* STEALTH FRAME */
function goFrame(url) {
const goFrame = url => {
localStorage.setItem("huframesrc", url);
window.location.href = "?s";
}
location.href = "?s";
};

function goToUrl(url, stealth, nolag) {
if (stealth) {
goFrame(url, nolag);
} else {
window.location.href = url;
}
}
const goToUrl = (url, stealth, nolag) => {
stealth ? goFrame(url, nolag) : location.href = url;
};

/* COOKIE AUTH DEMO */

function setAuthCookie(s, lax) {
document.cookie =
s +
"; expires=" +
(Date.now() + 259200) +
"; SameSite=" +
(lax ? "Lax" : "None") +
"; domain=." +
getDomain() +
"; path=/; Secure;";
}
const setAuthCookie = (s, lax) => {
document.cookie = s + `; expires=${Date.now() + 259200}; SameSite=${lax ? "Lax" : "None"}; domain=.${getDomain()}; path=/; Secure;`;
};

/* OMNIBOX */

const sx = "bing.com" + "/search?q=";

function omnibox(url) {
if (url.substring(0, 4) == "http") {
return url;
} else if (url.includes("." || "")) {
return "https://" + url;
} else {
return "https://" + sx + url;
}
}
const omnibox = url =>
(url.indexOf("http")
? "https://" + (url.indexOf(".") < 1 ? sx : "")
: "")
+ url;

function uvUrl(url) {
return (
location.origin + __uv$config.prefix + __uv$config.encodeUrl(omnibox(url))
);
}
const uvUrl = url => location.origin + __uv$config.prefix + __uv$config.encodeUrl(omnibox(url));

/* RAMMERHEAD CONFIGURATION */

Expand Down
8 changes: 4 additions & 4 deletions views/assets/js/csel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* -----------------------------------------------
/* Authors: OlyB
/* Authors: OlyB and Yoct
/* GNU Affero General Public License v3.0: https://www.gnu.org/licenses/agpl-3.0.en.html
/* Adapted and modified by yoct.
/* Adapted and modified by Yoct.
/* Settings Menu
/* ----------------------------------------------- */

Expand All @@ -13,7 +13,7 @@ date = date.toUTCString();

// All cookies should be secure and are intended to work in iframes.
const setCookie = (name, value) => {
document.cookie = name + `=${encodeURIComponent(value)}; expires=${date}; SameSite=None; Secure`;
document.cookie = name + `=${encodeURIComponent(value)}; expires=${date}; SameSite=None; Secure;`;
},

removeCookie = name => {
Expand Down Expand Up @@ -48,7 +48,7 @@ pageShowAds = () => {
let advertising = document.createElement("style");
advertising.id = "advertising";
advertising.innerText = ".ad { display:block; }";
document.appendChild.bind(document.head || document.body || document.documentElement || document)(advertising);
(document.head || document.body || document.documentElement || document).appendChild(advertising);
},

// Remove the stylesheet made by the function above, if it exists.
Expand Down

0 comments on commit 75b8703

Please sign in to comment.