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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.5 - 2014-02-11
|
* 4chan X - Version 1.3.5 - 2014-02-12
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
@ -5471,7 +5471,6 @@
|
|||||||
QR.cleanNotifications();
|
QR.cleanNotifications();
|
||||||
d.activeElement.blur();
|
d.activeElement.blur();
|
||||||
$.rmClass(QR.nodes.el, 'dump');
|
$.rmClass(QR.nodes.el, 'dump');
|
||||||
$.rmClass(QR.nodes.el, 'url');
|
|
||||||
if (!Conf['Captcha Warning Notifications']) {
|
if (!Conf['Captcha Warning Notifications']) {
|
||||||
if (QR.captcha.isEnabled) {
|
if (QR.captcha.isEnabled) {
|
||||||
$.rmClass(QR.captcha.nodes.input, 'error');
|
$.rmClass(QR.captcha.nodes.input, 'error');
|
||||||
@ -5664,7 +5663,48 @@
|
|||||||
QR.handleFiles(files);
|
QR.handleFiles(files);
|
||||||
return $.addClass(QR.nodes.el, 'dump');
|
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) {
|
handleFiles: function(files) {
|
||||||
var file, isSingle, max, _i, _len;
|
var file, isSingle, max, _i, _len;
|
||||||
if (this !== QR) {
|
if (this !== QR) {
|
||||||
|
|||||||
BIN
builds/crx.crx
BIN
builds/crx.crx
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// 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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
@ -5474,7 +5474,6 @@
|
|||||||
QR.cleanNotifications();
|
QR.cleanNotifications();
|
||||||
d.activeElement.blur();
|
d.activeElement.blur();
|
||||||
$.rmClass(QR.nodes.el, 'dump');
|
$.rmClass(QR.nodes.el, 'dump');
|
||||||
$.rmClass(QR.nodes.el, 'url');
|
|
||||||
if (!Conf['Captcha Warning Notifications']) {
|
if (!Conf['Captcha Warning Notifications']) {
|
||||||
if (QR.captcha.isEnabled) {
|
if (QR.captcha.isEnabled) {
|
||||||
$.rmClass(QR.captcha.nodes.input, 'error');
|
$.rmClass(QR.captcha.nodes.input, 'error');
|
||||||
@ -5691,7 +5690,6 @@
|
|||||||
urlBlob = new Blob([this.response], {
|
urlBlob = new Blob([this.response], {
|
||||||
type: this.getResponseHeader('content-type')
|
type: this.getResponseHeader('content-type')
|
||||||
});
|
});
|
||||||
console.log(urlBlob.type);
|
|
||||||
if (urlBlob.type === null) {
|
if (urlBlob.type === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -269,18 +269,15 @@ QR =
|
|||||||
$.addClass QR.nodes.el, 'dump'
|
$.addClass QR.nodes.el, 'dump'
|
||||||
|
|
||||||
handleUrl: ->
|
handleUrl: ->
|
||||||
<% if (type === 'crx') { %>
|
|
||||||
url = prompt("Insert an url:")
|
url = prompt("Insert an url:")
|
||||||
return if url == null
|
return if url == null
|
||||||
|
<% if (type === 'crx') { %>
|
||||||
xhr = new XMLHttpRequest();
|
xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', url, true)
|
xhr.open('GET', url, true)
|
||||||
xhr.responseType = 'blob'
|
xhr.responseType = 'blob'
|
||||||
|
|
||||||
xhr.onload = (e) ->
|
xhr.onload = (e) ->
|
||||||
if this.readyState == this.DONE && xhr.status == 200
|
if this.readyState == this.DONE && xhr.status == 200
|
||||||
urlBlob = new Blob([this.response], {type : this.getResponseHeader('content-type')})
|
urlBlob = new Blob([this.response], {type : this.getResponseHeader('content-type')})
|
||||||
console.log(urlBlob.type)
|
|
||||||
return if urlBlob.type == null
|
return if urlBlob.type == null
|
||||||
unless urlBlob.type in QR.mimeTypes
|
unless urlBlob.type in QR.mimeTypes
|
||||||
QR.error "Unsupported file type."
|
QR.error "Unsupported file type."
|
||||||
@ -297,15 +294,35 @@ QR =
|
|||||||
xhr.send()
|
xhr.send()
|
||||||
return
|
return
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (type === 'currently-not-working-userscript') { %>
|
|
||||||
|
<% if (type === 'userscript') { %>
|
||||||
GM_xmlhttpRequest {
|
GM_xmlhttpRequest {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
responseType: 'blob',
|
overrideMimeType: "text/plain; charset=x-user-defined",
|
||||||
onload: (xhr) ->
|
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])
|
QR.handleFiles([urlBlob])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
onerror: (xhr) ->
|
||||||
|
QR.error "Can't load image."
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user