diff --git a/index.html b/index.html index 648179d9..071986f4 100644 --- a/index.html +++ b/index.html @@ -13263,6 +13263,11 @@ if (standalone) { script.src = "mods/steam_port.js"; document.head.appendChild(script); } + else if (standaloneType === "discord") { + var script = document.createElement('script'); + script.src = "mods/discord_port.js"; + document.head.appendChild(script); + } document.documentElement.classList.add("standalone"); } diff --git a/mods/discord_port.js b/mods/discord_port.js new file mode 100644 index 00000000..d6ec560f --- /dev/null +++ b/mods/discord_port.js @@ -0,0 +1,36 @@ +// For the Sandboxels Discord activity: https://discord.com/oauth2/authorize?client_id=1360770918732796117 + +function convertListeners() { + document.querySelectorAll("*[onclick]").forEach((e) => { + e.addEventListener("click", e.onclick); + e.removeAttribute("onclick"); + }) + document.querySelectorAll("*[oninput]").forEach((e) => { + e.addEventListener("input", e.oninput); + e.removeAttribute("oninput"); + }) + document.querySelectorAll("*[onchange]").forEach((e) => { + e.addEventListener("change", e.onchange); + e.removeAttribute("onchange"); + }) +} + +_showPromptScreen = showPromptScreen; +showPromptScreen = function() { + _showPromptScreen(); + convertListeners(); +} + +_showInfo = showInfo; +showInfo = function() { + _showInfo(); + convertListeners(); +} + +_getDiscordSaves = getDiscordSaves; +getDiscordSaves = function() { + _getDiscordSaves(); + convertListeners(); +} + +window.addEventListener("load", convertListeners); \ No newline at end of file