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