Skip to content

Commit

Permalink
Fix critical issue with memory collapse in dedicated server when usin…
Browse files Browse the repository at this point in the history
…g preventDefault on recievechatmessage
  • Loading branch information
ZXMushroom63 committed Sep 8, 2024
1 parent 661c3d9 commit 266eda5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions postinit.injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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")) {
Expand All @@ -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")) {
Expand All @@ -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")) {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion postinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 266eda5

Please sign in to comment.