Skip to content

Instantly share code, notes, and snippets.

@michael-land
Created March 16, 2021 20:30
Show Gist options
  • Save michael-land/32172a1540f1b48037fdf12342e6aadd to your computer and use it in GitHub Desktop.
Save michael-land/32172a1540f1b48037fdf12342e6aadd to your computer and use it in GitHub Desktop.
twinportspool.com
const e=document.createElement("button");e.id="uploader",e.innerText="upload logo to JTD 220",document.body.append(e),e.addEventListener("click",(async()=>{const e=document.querySelector("#coreBoardForm"),o=new FormData(e);o.set("GenerateScoreboardButton","Download+Scoreboard");const t=await fetch("https://www.twinportspool.com/sb.aspx",{body:new URLSearchParams(o),method:"POST",mode:"cors",credentials:"include"}),n=await t.blob(),a=new FormData;a.append("myFile",n,"image.png");try{const e=await fetch("https://4d7de8574216.ngrok.io/upload",{method:"POST",body:a});if(console.log(e.ok),e.ok){const e=document.createElement("div");e.innerHTML="Your image uploaded successfully",document.body.append(e),setTimeout((()=>{e.parentNode.removeChild(e)}),1e3)}else alert("Opps, something wrong while uploading your image")}catch(r){console.log(r),alert("Opps, something wrong while uploading your image")}}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment