From feb27007eba34a99d248e231b55c5998d226111c Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 15 Dec 2020 11:27:23 -0500 Subject: [PATCH] Use URL property from upload response This updates the extension to work with the latest Snap.as API and fixes the copy-to-clipboard functionality that broke with recent API changes. --- uploader.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/uploader.js b/uploader.js index 3ac7e99..9f31992 100644 --- a/uploader.js +++ b/uploader.js @@ -41,14 +41,8 @@ Dropzone.options.uploader = { dictDefaultMessage: 'Drop a file here', init: function() { this.on("success", function(file, resp) { - var fp = file.name.split(/\./); - var ext = ''; - if (fp.length > 0) { - ext = '.' + fp[fp.length - 1]; - } - var env = JSON.parse(resp); - var url = 'https://i.snap.as/' + env.data + ext; - copyToClipboard('![](' + url + ')'); + var data = resp; + copyToClipboard('![](' + data.data.url + ')'); chrome.runtime.sendMessage({success: true}, function(response) { }); window.close(); });