diff options
Diffstat (limited to 'html')
| -rw-r--r-- | html/wasm.html | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/html/wasm.html b/html/wasm.html index a839ef6b..197836ff 100644 --- a/html/wasm.html +++ b/html/wasm.html @@ -56,6 +56,34 @@ if (!WebAssembly.instantiateStreaming) { // polyfill }; } +// Hook the console log to send debug information +// See: https://stackoverflow.com/questions/19846078/how-to-read-from-chromes-console-in-javascript#19846113 +console.oldlog = console.log.bind(console); +console.logs = []; +console.log = function(){ + console.logs.push(Array.from(arguments)); + console.oldlog.apply(console, arguments); +} + +function mailLogs() { + let mailtoLink = new URL("mailto:muhqs-game-logs@muhq.space"); + mailtoLink.searchParams.append("subject", encodeURIComponent("muhqs-game crash report")); + mailtoLink.searchParams.append("body", encodeURIComponent(console.logs)); + console.log(mailtoLink); + + if (window.confirm('Send a bug report and help to improve muhqs-game.')) { + window.open(mailtoLink, '_system'); + }; +} + +console.oldwarn = console.warn.bind(console); +console.warn = function() { + if (arguments[0] === "exit code:" && arguments[1] != 0) { + mailLogs(); + } + console.oldwarn.apply(console, arguments); +} + const go = new Go(); let mod, inst; let url = new URLSearchParams(window.location.search).get("wasm"); |
