diff --git a/postinit.injector.js b/postinit.injector.js index 0631739..f8bfebf 100644 --- a/postinit.injector.js +++ b/postinit.injector.js @@ -27,7 +27,7 @@ globalThis.modapi_postinit = `(() => { } } ModAPI.meta.title = function (title) { - if (document.currentScript.getAttribute("data-isMod") !== "true") { + if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") { return console.log("[ModAPIMeta] Cannot set meta for non-mod script."); } if (!document.currentScript.hasAttribute("data-hash")) { @@ -36,7 +36,7 @@ globalThis.modapi_postinit = `(() => { ModAPI.meta._titleMap[document.currentScript.getAttribute("data-hash")] = limitSize(title, 14); } ModAPI.meta.icon = function (iconSrc) { - if (document.currentScript.getAttribute("data-isMod") !== "true") { + if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") { return console.log("[ModAPIMeta] Cannot set meta for non-mod script."); } if (!document.currentScript.hasAttribute("data-hash")) { @@ -45,7 +45,7 @@ globalThis.modapi_postinit = `(() => { ModAPI.meta._iconMap[document.currentScript.getAttribute("data-hash")] = iconSrc; } ModAPI.meta.credits = function (cd) { - if (document.currentScript.getAttribute("data-isMod") !== "true") { + if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") { return console.log("[ModAPIMeta] Cannot set meta for non-mod script."); } if (!document.currentScript.hasAttribute("data-hash")) { @@ -54,7 +54,7 @@ globalThis.modapi_postinit = `(() => { ModAPI.meta._developerMap[document.currentScript.getAttribute("data-hash")] = limitSize(cd, 16); } ModAPI.meta.description = function (desc) { - if (document.currentScript.getAttribute("data-isMod") !== "true") { + if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") { return console.log("[ModAPIMeta] Cannot set meta for non-mod script."); } if (!document.currentScript.hasAttribute("data-hash")) { @@ -621,7 +621,7 @@ globalThis.modapi_postinit = `(() => { } ModAPI.events.callEvent("processcommand", data); if (data.preventDefault) { - return; + return 0; } if (typeof data.command === "string") { ModAPI.util.setStringContent($rawCommand, data.command) diff --git a/postinit.js b/postinit.js index 15dcefd..c2a9c8a 100644 --- a/postinit.js +++ b/postinit.js @@ -621,7 +621,7 @@ } ModAPI.events.callEvent("processcommand", data); if (data.preventDefault) { - return; + return 0; } if (typeof data.command === "string") { ModAPI.util.setStringContent($rawCommand, data.command)