From 552f8ae4e983b84c2d6a4cc99590e2e4f469a77c Mon Sep 17 00:00:00 2001 From: 00Fjongl <65314359+00Fjongl@users.noreply.github.com> Date: Sun, 7 Jul 2024 02:10:12 -0500 Subject: [PATCH] More commenting and reformatting. --- src/randomization.mjs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/randomization.mjs b/src/randomization.mjs index d37975a7..6d94f0a3 100644 --- a/src/randomization.mjs +++ b/src/randomization.mjs @@ -25,36 +25,47 @@ const insertText = (lis, str, newText) => { return str; }; -const randomListItem = lis => lis[Math.random() * lis.length | 0]; -const charset = ["­", "​", "­"]; -const insertCharset = str => insertText( + +// Below are lots of function definitions used to obfuscate the website. +// This makes the website harder to properly categorize, as its source code +// changes with each time it is loaded. +const randomListItem = lis => () => lis[Math.random() * lis.length | 0], + +charset = ["­", "​", "­"], +insertCharset = str => insertText( charset, str, - () => randomListItem(charRandom) -); + randomListItem(charRandom) +), -const hutaoInsert = str => insertText( +hutaoInsert = str => insertText( "", str, - () => randomListItem(splashRandom) -); + randomListItem(splashRandom) +), -const insertCooking = str => insertText( +cookingText = () => `${randomListItem(cookingInserts)()}`, +insertCooking = str => insertText( "", str, - () => `${randomListItem(cookingInserts)}` -); + cookingText +), -const cacheBusting = str => { +// This one isn't for obfuscation; it's just for dealing with cache issues. +cacheBusting = str => { for (let item of Object.entries(cacheBustList)) str = insertText(item[0], str, item[1]); return str; }; -export const paintSource = str => insertCharset(hutaoInsert(insertCooking(cacheBusting(str)))); -export const tryReadFile = file => existsSync(file) ? readFileSync(file, "utf8") : text404; + +// Applies the final obfuscation changes to an entire file. +export const paintSource = str => insertCharset(hutaoInsert(insertCooking(cacheBusting(str)))), + +// Grabs the text content of a file. +tryReadFile = file => existsSync(file) ? readFileSync(file, "utf8") : text404; /* // All of this is now old code.