From 8d20d0b4eca733d02c87c7ddbda6ec9ddce48462 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 19 Sep 2018 14:00:16 -0700 Subject: [PATCH] Use event page for downloading file in all cases due to AJAX blocking. #2066 --- src/platform/CrossOrigin.coffee | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/platform/CrossOrigin.coffee b/src/platform/CrossOrigin.coffee index bf069b1a2..ae381666e 100644 --- a/src/platform/CrossOrigin.coffee +++ b/src/platform/CrossOrigin.coffee @@ -14,24 +14,9 @@ CrossOrigin = # XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310 url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/' <% if (type === 'crx') { %> - parts = url.split '/' - if parts[0] is location.protocol and parts[1] is '' and ImageHost.test(parts[2]) - xhr = new XMLHttpRequest() - xhr.open 'GET', url, true - xhr.setRequestHeader key, value for key, value of headers - xhr.responseType = 'arraybuffer' - xhr.onload = -> - return cb null unless @readyState is @DONE and @status in [200, 206] - contentType = @getResponseHeader 'Content-Type' - contentDisposition = @getResponseHeader 'Content-Disposition' - cb new Uint8Array(@response), contentType, contentDisposition - xhr.onerror = xhr.onabort = -> - cb null - xhr.send() - else - eventPageRequest url, 'arraybuffer', ({response, contentType, contentDisposition, error}) -> - return cb null if error - cb new Uint8Array(response), contentType, contentDisposition + eventPageRequest url, 'arraybuffer', ({response, contentType, contentDisposition, error}) -> + return cb null if error + cb new Uint8Array(response), contentType, contentDisposition <% } %> <% if (type === 'userscript') { %> # Use workaround for binary data in Greasemonkey versions < 3.2, in Pale Moon for all GM versions, and in JS Blocker (Safari).