From 2893d85d872b76f7089def67362fff622393581f Mon Sep 17 00:00:00 2001 From: falquinho Date: Tue, 22 May 2018 01:37:14 -0300 Subject: [PATCH] Fixed error preventing uploaded payloads to be sent. --- main.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index ab03369..c546760 100644 --- a/main.js +++ b/main.js @@ -133,6 +133,15 @@ document.getElementById("goButton").addEventListener("click", async () => { var debugCheckbox = document.getElementById("shouldDebug"); const payloadType = document.getElementById("payloadSelect").value; + logOutput("Requesting access to device..."); + try { + device = await navigator.usb.requestDevice({ filters: [{ vendorId: 0x0955 }] }); + } catch (error) { + console.log(error); + logOutput("Failed to get a device. Did you chose one?"); + return; + } + let payload; if (payloadType === "hekate v5") { payload = hekate5; @@ -157,6 +166,7 @@ document.getElementById("goButton").addEventListener("click", async () => { } logOutput("Using uploaded payload \"" + file.name + "\""); payload = new Uint8Array(await readFileAsArrayBuffer(file)); + } else { logOutput("You're trying to load a payload type that doesn't exist."); return; @@ -174,9 +184,6 @@ document.getElementById("goButton").addEventListener("click", async () => { return; } - logOutput("Requesting access to device..."); - device = await navigator.usb.requestDevice({ filters: [{ vendorId: 0x0955 }] }); - logOutput(`Preparing to launch ${payloadType}...`); launchPayload(payload); });