From a81bb6e6c72c274b54459f113d74f7e024d50012 Mon Sep 17 00:00:00 2001 From: O-01-67 <68935009+O-01-67@users.noreply.github.com> Date: Fri, 7 Oct 2022 22:02:24 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit thing-paradoxically-required-for-itself moment --- mods/require_mod.js | 90 --------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 mods/require_mod.js diff --git a/mods/require_mod.js b/mods/require_mod.js deleted file mode 100644 index fb197049..00000000 --- a/mods/require_mod.js +++ /dev/null @@ -1,90 +0,0 @@ -xor = function(c1,c2) { - if(!!c1 && !c2) { - return true; - } else if(!c1 && !!c2) { - return true; - } else { - return false; - }; -}; - -nand = function(c1,c2) { - return (!c1 && !c2); -}; - -function requireMod(modName,doAlert=false,insertMod=false,simpleSandboxelsSubdomainMod=true) { - if(simpleSandboxelsSubdomainMod) { - var finalString = modName; - if(!modName.startsWith("mods/")) { - //console.log("The 'mods/' prefix is missing! It will be added to the string."); - finalString = "mods/" + finalString; - }; - if(!modName.endsWith(".js")) { - //console.log("The '.js' suffix is missing! It will be added to the string."); - finalString += ".js"; - }; - //console.log(finalString); - if(enabledMods.includes(finalString)) { - console.log(`requireMod: The entry '${finalString}' was present; no action was taken.`); - return true; - } else { - //compile summary string for console.log - var summaryString = `requireMod: The entry '${finalString}' was not present`; //base - if(xor(doAlert,insertMod)) { //one option enabled - if(doAlert) { summaryString += "; the user was alerted." } //it is alert - else if(insertMod) { summaryString += "; the mod was inserted." }; //it is insert - } else if(doAlert && insertMod) { //both enabled - summaryString += "; the user was alerted and the mod inserted." - } else if(nand(doAlert,insertMod)) { //neither enabled - summaryString += "; no action was taken."; - }; console.log(summaryString); - - var alertString = `The "${modName}" mod is required`; - if(insertMod) { - enabledMods.splice(enabledMods.length, 0, finalString); - localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); - //console.log("(Pretend to add mod)"); - alertString += " and has been automatically appended to your mod list (reload for this to take effect). If you need it at a certain position, do this in the mod manager after reloading." - } else { - alertString += "! Please add it to your mod list in the mod manager and reload." - }; - if(doAlert) { - alert(alertString); - }; - return false; - }; - } else { - var finalString = modName; - //console.log(finalString); - if(enabledMods.includes(finalString)) { - console.log(`requireMod: The entry '${finalString}' was present; no action was taken.`); - return true; - } else { - if(insertMod) { doAlert = true }; //so that mods don't try to silently insert malicious scripts (just in case); - //compile summary string for console.log - var summaryString = `requireMod: The entry '${finalString}' was not present`; //base - if(xor(doAlert,insertMod)) { //one option enabled - if(doAlert) { summaryString += "; the user was alerted." } //it is alert - else if(insertMod) { summaryString += "; the mod was inserted." }; //it is insert - } else if(doAlert && insertMod) { //both enabled - summaryString += "; the user was alerted and the mod inserted." - } else if(nand(doAlert,insertMod)) { //neither enabled - summaryString += "; no action was taken."; - }; console.log(summaryString); - - var alertString = `The mod at "${modName}" is required`; - if(insertMod) { - enabledMods.splice(enabledMods.length, 0, finalString); - localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); - //console.log("(Pretend to add mod)"); - alertString += " and has been automatically appended to your mod list (reload for this to take effect). If you need it at a certain position, do this in the mod manager after reloading.\n\nI recommend opening that URL and looking at the mod's source code before reloading, and removing it through the console or by clearing Sandboxels's site data if it looks suspicious." - } else { - alertString += "! Please add it to your mod list in the mod manager and reload." - }; - if(doAlert) { - alert(alertString); - }; - return false; - }; - }; -};