rj1
about | log | files | refs | license
commit b43bcaab0e6d5362c59bdd2a7ee9ce4fa68a4637
parent a5b2c3e9fb4269600b3796bd795ff9b710143530
author: rj1 <[email protected]>
date:   Mon, 19 Sep 2022 04:15:10 -0500

bugfix: file uploads were using previous file's format, changed filehole url length to 5

Diffstat:
Mmanifest.json | 2+-
Mupload.js | 35+++++++++++++++--------------------
2 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/manifest.json b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "POST Image", - "version": "0.4", + "version": "0.5", "icons": { "200": "icon.png" }, diff --git a/upload.js b/upload.js @@ -1,30 +1,25 @@ browser.contextMenus.create({ title: "Upload image [POST]", contexts: ["image"], - onclick: function(info, tab) { + onclick: function(info) { var download = new XMLHttpRequest(); download.onload = function() { - var og_filename = info.srcUrl.split(/[\\/]/).pop(); // maybe we'll use this later - formatDetect(download.response, function(extension) { - filename = makeid(5) + '.' + extension; - }); - - var fd = new FormData(); - fd.append("file", download.response, filename); - fd.append("url_len", "8"); - var upload = new XMLHttpRequest(); - upload.responseType = 'text'; - - upload.onload = function() { - url = upload.response - browser.tabs.create({url: url}); - } - - // upload image - upload.open('POST', 'https://filehole.org/'); - upload.send(fd); + var filename = makeid(5) + '.' + extension; + var fd = new FormData(); + fd.append("file", download.response, filename); + fd.append("url_len", "5"); + var upload = new XMLHttpRequest(); + upload.responseType = 'text'; + upload.onload = function() { + url = upload.response + browser.tabs.create({url: url}); + } + // upload image + upload.open('POST', 'https://filehole.org/'); + upload.send(fd); + }); }; download.responseType = 'blob';