diff --git a/pages/home.html b/pages/home.html index 127f474..30bff4e 100644 --- a/pages/home.html +++ b/pages/home.html @@ -82,7 +82,7 @@

diff --git a/public/js/home.js b/public/js/home.js index 4412ac5..83e935a 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -172,6 +172,29 @@ upload.prepareDropzone = function(){ }); + upload.prepareShareX(); +} + +upload.prepareShareX = function(){ + if (upload.token) { + var sharex_element = document.getElementById("ShareX"); + var sharex_file = "{\r\n\ + \"Name\": \"" + location.hostname + "\",\r\n\ + \"DestinationType\": \"ImageUploader, FileUploader\",\r\n\ + \"RequestType\": \"POST\",\r\n\ + \"RequestURL\": \"" + location.origin + "/api/upload\",\r\n\ + \"FileFormName\": \"files[]\",\r\n\ + \"Headers\": {\r\n\ + \"token\": \" " + upload.token + "\"\r\n\ + },\r\n\ + \"ResponseType\": \"Text\",\r\n\ + \"URL\": \"$json:files[0].url$\",\r\n\ + \"ThumbnailURL\": \"$json:files[0].url$\"\r\n\ +}"; + var sharex_blob = new Blob([sharex_file], {type: "application/octet-binary"}); + sharex_element.setAttribute("href", URL.createObjectURL(sharex_blob)) + sharex_element.setAttribute("download", location.hostname + ".sxcu"); + } } //Handle image paste event