Skip to content

Commit

Permalink
chore: remove old code, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
00Fjongl committed Feb 7, 2025
1 parent e9aa87d commit f139eb6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 319 deletions.
135 changes: 0 additions & 135 deletions src/express.mjs

This file was deleted.

40 changes: 1 addition & 39 deletions src/randomization.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const config = Object.freeze(
insertCharset(hutaoInsert(versionInsert(insertCooking(cacheBusting(str))))),
// Use this instead of text404 for a preloaded error page.
preloaded404 = paintSource(text404),
// Grab the text content of a file. Uses the root directory if no base is supplied.
// Grab the text content of a file. Use the root directory if no base is supplied.
tryReadFile = (file, baseUrl = new URL('../', import.meta.url)) => {
file = new URL(file, baseUrl);
return existsSync(file)
Expand All @@ -89,41 +89,3 @@ const config = Object.freeze(
)
: preloaded404;
};

/*
All of this is now old code.
The newer versions of these functions are directly above.
function randomListItem(lis) {
return lis[Math.floor(Math.random() * lis.length)];
}
function insertCharset(str) {
return str.replace(/&#173;|&#8203;|&shy;|<wbr>/g, function() { return randomListItem(charRandom); });
}
function hutaoInsert(str) {
return str.replace(/<!--HUTAOWOA-->/g, function() { return randomListItem(splashRandom); });
}
function insertCooking(str) {
return str.replace(/<!-- IMPORTANT-HUCOOKINGINSERT-DONOTDELETE -->/g, function() { return '<span style="display: none;" data-fact="' + randomListItem(vegetables) + '" data-type="' + randomListItem(vegetables) + '">' + randomListItem(cookingInserts) + '</span>'; }); // this needs to be inside a function, so that not every string is the same
}
function cacheBusting(str) {
for (var item of Object.entries(cacheBustList)) {
str = str.replace(new RegExp(item[0], "g"), item[1]);
}
return str;
}
export function paintSource(str) {
return insertCharset(hutaoInsert(insertCooking(cacheBusting(str))));
}
export function tryReadFile(file) {
return existsSync(file) ? readFileSync(file, 'utf8') : text404;
}
*/
2 changes: 1 addition & 1 deletion src/routes.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';

const pages = {
// If you are trying to add pages or assets in the root folder and
Expand Down
14 changes: 7 additions & 7 deletions views/assets/js/common-1735118314.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const setAuthCookie = (s, lax) => {

/* OMNIBOX */

// Search engine is set to Bing. Intended to work just like the usual
// Search engine is set to DuckDuckGo. Intended to work just like the usual
// bar at the top of a browser.
const sx = 'duckduckgo.com/?q=',
/*
Expand All @@ -75,11 +75,11 @@ const sx = 'duckduckgo.com/?q=',
// Another omnibox function. Unsure if the version above is needed.
search = (input, template = `https://${sx}%s`) => {
try {
// Return the input if it is already a valid URL.
// eg: https://example.com, https://example.com/test?q=param
// Return the input if it is already a valid URL.
// eg: https://example.com, https://example.com/test?q=param
return new URL(input) + '';
} catch (e) {
// Continue if it is invalid.
// Continue if it is invalid.
}

try {
Expand Down Expand Up @@ -241,9 +241,9 @@ const RammerheadEncode = async (baseUrl) => {
});
},
},
/* Organize Rammerhead sessions via the browser's local storage.
* Local data consists of session creation timestamps and session IDs.
* The rest of the data is stored on the server.
/* Organize Rammerhead sessions via the browser's local storage.
* Local data consists of session creation timestamps and session IDs.
* The rest of the data is stored on the server.
*/
localStorageKey = 'rammerhead_sessionids',
localStorageKeyDefault = 'rammerhead_default_sessionid',
Expand Down
137 changes: 0 additions & 137 deletions views/assets/js/csel.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,140 +240,3 @@ if (document.getElementById('csel')) {
});
}
})();

/* -----------------------------------------------
/* Original code written by OlyB
/* -----------------------------------------------
(function() {
let date = new Date();
date.setFullYear(date.getFullYear() + 100);
date = date.toUTCString();
let csel = document.getElementById("csel");
function setCookie(name, value) {
document.cookie = name + "=" + encodeURIComponent(value) + "; expires=" + date + "; ";
}
function removeCookie(name) {
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:01 GMT; ";
}
async function readCookie(name) {
let cookie = document.cookie.split("; ");
let cookies = {};
for (let i = 0; i < cookie.length; i++) {
let p = cookie[i].split("=");
cookies[p[0]] = p[1];
}
return decodeURIComponent(cookies[name]);
}
function pageTitle(value) {
let tag = document.getElementsByTagName("title")[0] || document.createElement("title");
tag.innerHTML = value;
document.head.appendChild(tag);
}
function pageIcon(value) {
let tag = document.querySelector("link[rel*='icon']") || document.createElement("link");
tag.rel = "icon";
tag.href = value;
document.head.appendChild(tag);
}
function setTitle(value) {
pageTitle(value);
setCookie("HBTitle", value);
}
function setIcon(value) {
pageIcon(value);
setCookie("HBIcon", value);
}
function pageHideAds() {
document.querySelectorAll(".ad").forEach(n => n.style.display = "none");
}
function pageShowAds() {
document.querySelectorAll(".ad").forEach(n => n.style.display = "block");
}
function hideAds() {
pageHideAds();
setCookie("HBHideAds", "true");
}
// Ghetto Default Disable Ads
setCookie("HBHideAds", "true");
function showAds() {
pageShowAds();
removeCookie("HBHideAds");
}
readCookie("HBTitle").then(s => (s != "undefined") && pageTitle(s));
readCookie("HBIcon").then(s => (s != "undefined") && pageIcon(s));
readCookie("HBHideAds").then(s => (s != "undefined") && (function() { pageHideAds(); (document.getElementById("hideads") || {}).checked = "true"; })());
if (csel) {
csel.innerHTML =
decodeURIComponent(atob("JTNDcCUyMGNsYXNzJTNEJTIyY3NlbHRpdGxlJTIyJTNFVGFiJTIwQ2xvYWslM0MlMkZwJTNFJTBBJTNDcCUyMGNsYXNzJTNEJTIyY3NlbGxhYmVsJTIyJTNFQ2hhbmdlJTIwdGhlJTIwdGl0bGUlM0ElM0MlMkZwJTNFJTBBJTNDZm9ybSUyMGNsYXNzJTNEJTIyY3NlbGZvcm0lMjIlMjBpZCUzRCUyMnRpdGxlZm9ybSUyMiUzRSUwQSUyMCUyMCUyMCUyMCUzQ2lucHV0JTIwdHlwZSUzRCUyMnRleHQlMjIlMjBwbGFjZWhvbGRlciUzRCUyMlRhYiUyMFRpdGxlJTIyJTIwc3BlbGxjaGVjayUzRCUyMmZhbHNlJTIyJTNFJTNDaW5wdXQlMjBjbGFzcyUzRCUyM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BBJTIwJTIwJTIwJTIwJTNDc3BhbiUzRUhpZGUlMjBBZHMlM0MlMkZzcGFuJTNFJTBBJTNDJTJGcCUzRSUwQSUzQ3AlM0VBZHMlMjBoZWxwJTIwc3VwcG9ydCUyMEglMjYlMjMxNzMlM0JvJTI2JTIzMTczJTNCbHklMjBVJTI2JTIzMTczJTNCbmIlMjYlMjMxNzMlM0Jsb2NrJTI2JTIzMTczJTNCZXIhJTNDJTJGcCUzRQ=="));
document.getElementById("titleform").addEventListener("submit", function(e) {
e.preventDefault();
if (this.firstElementChild.value) {
setTitle(this.firstElementChild.value);
this.firstElementChild.value = "";
} else {
alert("Please provide a title.");
}
}, false);
document.getElementById("iconform").addEventListener("submit", function(e) {
e.preventDefault();
if (this.firstElementChild.value) {
setIcon(this.firstElementChild.value);
this.firstElementChild.value = "";
} else {
alert("Please provide an icon URL.");
}
}, false);
document.getElementById("cselreset").addEventListener("click", function() {
if (confirm("Reset the title and icon to default?")) {
removeCookie("HBTitle");
removeCookie("HBIcon");
pageTitle("H&shy;o&shy;ly Un&shy;blo&shy;ck&shy;er");
pageIcon("assets/img/icon.png");
}
}, false);
document.getElementById("cselab").addEventListener("click", function () {
var win = window.open()
var url = `${window.location.href}`
var iframe = win.document.createElement('iframe')
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.border = "none";
iframe.style.overflow = "hidden";
iframe.style.margin = "0";
iframe.style.padding = "0";
iframe.style.position = "fixed";
iframe.style.top = "0";
iframe.style.bottom = "0";
iframe.style.left = "0";
iframe.style.right = "0";
iframe.src = url;
win.document.body.appendChild(iframe)
});
document.getElementById("hideads").addEventListener("change", function(e) {
e.target.checked ? hideAds() : showAds();
}, false);
}
})();
*/

0 comments on commit f139eb6

Please sign in to comment.