Fix posting from url in Firefox
This commit is contained in:
parent
eeb95bbb9f
commit
15d8da033a
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 4chan X - Version 1.3.5 - 2014-02-11
|
||||
* 4chan X - Version 1.3.5 - 2014-02-12
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* 4chan X - Version 1.3.5 - 2014-02-11
|
||||
* 4chan X - Version 1.3.5 - 2014-02-12
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||
@ -5471,7 +5471,6 @@
|
||||
QR.cleanNotifications();
|
||||
d.activeElement.blur();
|
||||
$.rmClass(QR.nodes.el, 'dump');
|
||||
$.rmClass(QR.nodes.el, 'url');
|
||||
if (!Conf['Captcha Warning Notifications']) {
|
||||
if (QR.captcha.isEnabled) {
|
||||
$.rmClass(QR.captcha.nodes.input, 'error');
|
||||
@ -5664,7 +5663,48 @@
|
||||
QR.handleFiles(files);
|
||||
return $.addClass(QR.nodes.el, 'dump');
|
||||
},
|
||||
handleUrl: function() {},
|
||||
handleUrl: function() {
|
||||
var url;
|
||||
url = prompt("Insert an url:");
|
||||
if (url === null) {
|
||||
return;
|
||||
}
|
||||
GM_xmlhttpRequest({
|
||||
method: "GET",
|
||||
url: url,
|
||||
overrideMimeType: "text/plain; charset=x-user-defined",
|
||||
onload: function(xhr) {
|
||||
var data, end, header, i, mime, r, start, urlBlob, _ref;
|
||||
r = xhr.responseText;
|
||||
data = new Uint8Array(r.length);
|
||||
i = 0;
|
||||
while (i < r.length) {
|
||||
data[i] = r.charCodeAt(i);
|
||||
i++;
|
||||
}
|
||||
header = xhr.responseHeaders;
|
||||
start = header.indexOf("Content-Type: ") + 14;
|
||||
end = header.substr(start, header.length).indexOf("\n") - 1;
|
||||
mime = header.substr(start, end);
|
||||
if (mime === null) {
|
||||
return;
|
||||
}
|
||||
urlBlob = new Blob([data], {
|
||||
type: mime
|
||||
});
|
||||
if (_ref = urlBlob.type, __indexOf.call(QR.mimeTypes, _ref) < 0) {
|
||||
QR.error("Unsupported file type.");
|
||||
}
|
||||
QR.handleFiles([urlBlob]);
|
||||
return;
|
||||
return {
|
||||
onerror: function(xhr) {
|
||||
return QR.error("Can't load image.");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
handleFiles: function(files) {
|
||||
var file, isSingle, max, _i, _len;
|
||||
if (this !== QR) {
|
||||
|
||||
BIN
builds/crx.crx
BIN
builds/crx.crx
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* 4chan X - Version 1.3.5 - 2014-02-11
|
||||
* 4chan X - Version 1.3.5 - 2014-02-12
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||
@ -5474,7 +5474,6 @@
|
||||
QR.cleanNotifications();
|
||||
d.activeElement.blur();
|
||||
$.rmClass(QR.nodes.el, 'dump');
|
||||
$.rmClass(QR.nodes.el, 'url');
|
||||
if (!Conf['Captcha Warning Notifications']) {
|
||||
if (QR.captcha.isEnabled) {
|
||||
$.rmClass(QR.captcha.nodes.input, 'error');
|
||||
@ -5691,7 +5690,6 @@
|
||||
urlBlob = new Blob([this.response], {
|
||||
type: this.getResponseHeader('content-type')
|
||||
});
|
||||
console.log(urlBlob.type);
|
||||
if (urlBlob.type === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -269,18 +269,15 @@ QR =
|
||||
$.addClass QR.nodes.el, 'dump'
|
||||
|
||||
handleUrl: ->
|
||||
<% if (type === 'crx') { %>
|
||||
url = prompt("Insert an url:")
|
||||
return if url == null
|
||||
|
||||
<% if (type === 'crx') { %>
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true)
|
||||
xhr.responseType = 'blob'
|
||||
|
||||
xhr.onload = (e) ->
|
||||
if this.readyState == this.DONE && xhr.status == 200
|
||||
urlBlob = new Blob([this.response], {type : this.getResponseHeader('content-type')})
|
||||
console.log(urlBlob.type)
|
||||
return if urlBlob.type == null
|
||||
unless urlBlob.type in QR.mimeTypes
|
||||
QR.error "Unsupported file type."
|
||||
@ -289,23 +286,43 @@ QR =
|
||||
else
|
||||
QR.error "Can't load image."
|
||||
return
|
||||
|
||||
|
||||
xhr.onerror = (e) ->
|
||||
QR.error "Can't load image."
|
||||
return
|
||||
|
||||
|
||||
xhr.send()
|
||||
return
|
||||
<% } %>
|
||||
<% if (type === 'currently-not-working-userscript') { %>
|
||||
|
||||
<% if (type === 'userscript') { %>
|
||||
GM_xmlhttpRequest {
|
||||
method: "GET",
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
overrideMimeType: "text/plain; charset=x-user-defined",
|
||||
onload: (xhr) ->
|
||||
urlBlob = new Blob([xhr.response], {type: 'image/png'})
|
||||
r = xhr.responseText
|
||||
data = new Uint8Array(r.length)
|
||||
i = 0
|
||||
while i < r.length
|
||||
data[i] = r.charCodeAt(i)
|
||||
i++
|
||||
#QUALITY coding at work
|
||||
header = xhr.responseHeaders
|
||||
start = header.indexOf("Content-Type: ") + 14
|
||||
end = header.substr(start, header.length).indexOf("\n") - 1
|
||||
mime = header.substr(start, end)
|
||||
return if mime is null
|
||||
|
||||
urlBlob = new Blob([data], {type: mime})
|
||||
unless urlBlob.type in QR.mimeTypes
|
||||
QR.error "Unsupported file type."
|
||||
|
||||
QR.handleFiles([urlBlob])
|
||||
return
|
||||
|
||||
onerror: (xhr) ->
|
||||
QR.error "Can't load image."
|
||||
}
|
||||
return
|
||||
<% } %>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user