Cleanup Post from URL code.
This commit is contained in:
parent
e96354bc3e
commit
1ffb8da5b7
@ -8971,7 +8971,7 @@
|
||||
},
|
||||
handleUrl: function() {
|
||||
var url;
|
||||
url = prompt("Insert an url:");
|
||||
url = prompt("Enter a URL:");
|
||||
if (url === null) {
|
||||
return;
|
||||
}
|
||||
@ -8980,16 +8980,17 @@
|
||||
url: url,
|
||||
overrideMimeType: "text/plain; charset=x-user-defined",
|
||||
onload: function(xhr) {
|
||||
var contentDisposition, contentType, data, i, r, _ref, _ref1;
|
||||
var contentDisposition, contentType, data, h, i, r;
|
||||
r = xhr.responseText;
|
||||
h = xhr.responseHeaders;
|
||||
data = new Uint8Array(r.length);
|
||||
i = 0;
|
||||
while (i < r.length) {
|
||||
data[i] = r.charCodeAt(i);
|
||||
i++;
|
||||
}
|
||||
contentType = (_ref = xhr.responseHeaders.match(/Content-Type:\s*(.*)/i)) != null ? _ref[1] : void 0;
|
||||
contentDisposition = (_ref1 = xhr.responseHeaders.match(/Content-Disposition:\s*(.*)/i)) != null ? _ref1[1] : void 0;
|
||||
contentType = (h.match(/Content-Type:\s*(.*)/i) || [])[1];
|
||||
contentDisposition = (h.match(/Content-Disposition:\s*(.*)/i) || [])[1];
|
||||
return QR.handleBlob(data, contentType, contentDisposition, url);
|
||||
},
|
||||
onerror: function(xhr) {
|
||||
|
||||
@ -9037,13 +9037,12 @@
|
||||
xhr.responseType = 'blob';
|
||||
xhr.onload = function(e) {
|
||||
var contentDisposition, contentType;
|
||||
if (this.readyState === this.DONE && xhr.status === 200) {
|
||||
contentType = this.getResponseHeader('Content-Type');
|
||||
contentDisposition = this.getResponseHeader('Content-Disposition');
|
||||
return QR.handleBlob(this.response, contentType, contentDisposition, url);
|
||||
} else {
|
||||
if (!(this.readyState === this.DONE && xhr.status === 200)) {
|
||||
return QR.error("Can't load image.");
|
||||
}
|
||||
contentType = this.getResponseHeader('Content-Type');
|
||||
contentDisposition = this.getResponseHeader('Content-Disposition');
|
||||
return QR.handleBlob(this.response, contentType, contentDisposition, url);
|
||||
};
|
||||
xhr.onerror = function(e) {
|
||||
return QR.error("Can't load image.");
|
||||
|
||||
@ -300,7 +300,7 @@ QR =
|
||||
QR.handleFiles([blob])
|
||||
|
||||
handleUrl: ->
|
||||
url = prompt("Insert an url:")
|
||||
url = prompt("Enter a URL:")
|
||||
return if url is null
|
||||
|
||||
<% if (type === 'crx') { %>
|
||||
@ -308,34 +308,42 @@ QR =
|
||||
xhr.open('GET', url, true)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.onload = (e) ->
|
||||
if @readyState is @DONE && xhr.status is 200
|
||||
contentType = @getResponseHeader('Content-Type')
|
||||
contentDisposition = @getResponseHeader('Content-Disposition')
|
||||
QR.handleBlob @response, contentType, contentDisposition, url
|
||||
else
|
||||
QR.error "Can't load image."
|
||||
return QR.error "Can't load image." unless @readyState is @DONE and xhr.status is 200
|
||||
|
||||
contentType = @getResponseHeader('Content-Type')
|
||||
contentDisposition = @getResponseHeader('Content-Disposition')
|
||||
QR.handleBlob @response, contentType, contentDisposition, url
|
||||
|
||||
xhr.onerror = (e) ->
|
||||
QR.error "Can't load image."
|
||||
xhr.send()
|
||||
<% } %>
|
||||
|
||||
<% if (type === 'userscript') { %>
|
||||
<% } else { %>
|
||||
|
||||
GM_xmlhttpRequest
|
||||
method: "GET"
|
||||
url: url
|
||||
|
||||
# FIXME: responseType: 'blob'
|
||||
# Could do it now, but don't wanna kill off legacy GM versions yet
|
||||
overrideMimeType: "text/plain; charset=x-user-defined"
|
||||
onload: (xhr) ->
|
||||
r = xhr.responseText
|
||||
data = new Uint8Array(r.length)
|
||||
i = 0
|
||||
r = xhr.responseText
|
||||
h = xhr.responseHeaders
|
||||
data = new Uint8Array r.length
|
||||
i = 0
|
||||
|
||||
while i < r.length
|
||||
data[i] = r.charCodeAt(i)
|
||||
data[i] = r.charCodeAt i
|
||||
i++
|
||||
contentType = xhr.responseHeaders.match(/Content-Type:\s*(.*)/i)?[1]
|
||||
contentDisposition = xhr.responseHeaders.match(/Content-Disposition:\s*(.*)/i)?[1]
|
||||
|
||||
contentType = (h.match(/Content-Type:\s*(.*)/i) or [])[1]
|
||||
contentDisposition = (h.match(/Content-Disposition:\s*(.*)/i) or [])[1]
|
||||
QR.handleBlob data, contentType, contentDisposition, url
|
||||
|
||||
onerror: (xhr) ->
|
||||
QR.error "Can't load image."
|
||||
|
||||
<% } %>
|
||||
|
||||
handleFiles: (files) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user