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.