From c775d088a7244d9d9f3fbe0201fecddd0918382c Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Thu, 3 Aug 2023 19:48:21 +0300 Subject: [PATCH] Update QuarklyUploadImageViaURL.user.js --- .../QuarklyUploadImageViaURL.user.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/QuarklyUploadImageViaURL/QuarklyUploadImageViaURL.user.js b/QuarklyUploadImageViaURL/QuarklyUploadImageViaURL.user.js index e04aa51..db21d27 100644 --- a/QuarklyUploadImageViaURL/QuarklyUploadImageViaURL.user.js +++ b/QuarklyUploadImageViaURL/QuarklyUploadImageViaURL.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Quarkly Upload Image via URL // @namespace http://tampermonkey.net/ -// @version 0.1 +// @version 0.2 // @description try to take over the world! // @author Maxim Slipenko // @match https://quarkly.io/project/* @@ -34,11 +34,17 @@ const finalUrl = r.finalUrl; // TODO: Better filename detection const filename = url.substring(url.lastIndexOf('/')+1); + var arr = r.responseHeaders.split('\r\n'); + var headers = arr.reduce(function (acc, current, i){ + var parts = current.split(': '); + acc[parts[0]] = parts[1]; + return acc; + }, {}); const file = new File( [r.response], filename, { - type:"image/jpeg", + type: headers['content-type'], lastModified:new Date().getTime() } );