Disable the QR if we're banned. Close #215.
This commit is contained in:
parent
fdef6b55d7
commit
da843081b2
@ -1839,10 +1839,18 @@
|
|||||||
return qr.message.send(post);
|
return qr.message.send(post);
|
||||||
},
|
},
|
||||||
response: function(html) {
|
response: function(html) {
|
||||||
var b, err, node, persona, postNumber, reply, thread, _, _ref;
|
var b, doc, err, node, persona, postNumber, reply, thread, _, _ref;
|
||||||
if (!(b = $('td b', $.el('a', {
|
doc = $.el('a', {
|
||||||
innerHTML: html
|
innerHTML: html
|
||||||
})))) {
|
});
|
||||||
|
if ($('title', doc).textContent === '4chan - Banned') {
|
||||||
|
qr.status({
|
||||||
|
ready: true,
|
||||||
|
banned: true
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(b = $('td b', doc))) {
|
||||||
err = 'Connection error with sys.4chan.org.';
|
err = 'Connection error with sys.4chan.org.';
|
||||||
} else if (b.childElementCount) {
|
} else if (b.childElementCount) {
|
||||||
if (b.firstChild.tagName) {
|
if (b.firstChild.tagName) {
|
||||||
@ -1901,8 +1909,11 @@
|
|||||||
return window.postMessage(data, '*');
|
return window.postMessage(data, '*');
|
||||||
},
|
},
|
||||||
receive: function(data) {
|
receive: function(data) {
|
||||||
var _ref;
|
var req, _ref;
|
||||||
switch (data.req) {
|
req = data.req;
|
||||||
|
delete data.req;
|
||||||
|
delete data.qr;
|
||||||
|
switch (req) {
|
||||||
case 'abort':
|
case 'abort':
|
||||||
if ((_ref = qr.ajax) != null) _ref.abort();
|
if ((_ref = qr.ajax) != null) _ref.abort();
|
||||||
return qr.message.send({
|
return qr.message.send({
|
||||||
@ -1920,7 +1931,6 @@
|
|||||||
var boundary, callbacks, form, i, name, opts, parts, toBin, url, val;
|
var boundary, callbacks, form, i, name, opts, parts, toBin, url, val;
|
||||||
url = "http://sys.4chan.org/" + data.board + "/post";
|
url = "http://sys.4chan.org/" + data.board + "/post";
|
||||||
delete data.board;
|
delete data.board;
|
||||||
delete data.qr;
|
|
||||||
if (engine === 'gecko' && data.upfile) {
|
if (engine === 'gecko' && data.upfile) {
|
||||||
if (!data.binary) {
|
if (!data.binary) {
|
||||||
toBin = function(data, name, val) {
|
toBin = function(data, name, val) {
|
||||||
@ -2003,7 +2013,17 @@
|
|||||||
'Content-Type': 'multipart/form-data;boundary=' + boundary
|
'Content-Type': 'multipart/form-data;boundary=' + boundary
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return qr.ajax = $.ajax(url, callbacks, opts);
|
try {
|
||||||
|
return qr.ajax = $.ajax(url, callbacks, opts);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.name === 'NETWORK_ERR') {
|
||||||
|
return qr.message.send({
|
||||||
|
req: 'status',
|
||||||
|
ready: true,
|
||||||
|
banned: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1411,7 +1411,12 @@ qr =
|
|||||||
qr.message.send post
|
qr.message.send post
|
||||||
|
|
||||||
response: (html) ->
|
response: (html) ->
|
||||||
unless b = $ 'td b', $.el('a', innerHTML: html)
|
doc = $.el 'a', innerHTML: html
|
||||||
|
# Check for ban.
|
||||||
|
if $('title', doc).textContent is '4chan - Banned'
|
||||||
|
qr.status ready: true, banned: true
|
||||||
|
return
|
||||||
|
unless b = $ 'td b', doc
|
||||||
err = 'Connection error with sys.4chan.org.'
|
err = 'Connection error with sys.4chan.org.'
|
||||||
else if b.childElementCount # error!
|
else if b.childElementCount # error!
|
||||||
if b.firstChild.tagName # duplicate image link
|
if b.firstChild.tagName # duplicate image link
|
||||||
@ -1474,7 +1479,10 @@ qr =
|
|||||||
parent
|
parent
|
||||||
window.postMessage data, '*'
|
window.postMessage data, '*'
|
||||||
receive: (data) ->
|
receive: (data) ->
|
||||||
switch data.req
|
req = data.req
|
||||||
|
delete data.req
|
||||||
|
delete data.qr
|
||||||
|
switch req
|
||||||
when 'abort'
|
when 'abort'
|
||||||
qr.ajax?.abort()
|
qr.ajax?.abort()
|
||||||
qr.message.send req: 'status'
|
qr.message.send req: 'status'
|
||||||
@ -1490,7 +1498,6 @@ qr =
|
|||||||
url = "http://sys.4chan.org/#{data.board}/post"
|
url = "http://sys.4chan.org/#{data.board}/post"
|
||||||
# Do not append these values to the form.
|
# Do not append these values to the form.
|
||||||
delete data.board
|
delete data.board
|
||||||
delete data.qr
|
|
||||||
|
|
||||||
# File with filename upload fix from desuwa
|
# File with filename upload fix from desuwa
|
||||||
if engine is 'gecko' and data.upfile
|
if engine is 'gecko' and data.upfile
|
||||||
@ -1557,7 +1564,12 @@ qr =
|
|||||||
opts.headers =
|
opts.headers =
|
||||||
'Content-Type': 'multipart/form-data;boundary=' + boundary
|
'Content-Type': 'multipart/form-data;boundary=' + boundary
|
||||||
|
|
||||||
qr.ajax = $.ajax url, callbacks, opts
|
try
|
||||||
|
qr.ajax = $.ajax url, callbacks, opts
|
||||||
|
catch e
|
||||||
|
# CORS disabled error: redirecting to banned page ;_;
|
||||||
|
if e.name is 'NETWORK_ERR'
|
||||||
|
qr.message.send req: 'status', ready: true, banned: true
|
||||||
|
|
||||||
options =
|
options =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user