Disable the QR if we're banned. Close #215.

This commit is contained in:
Nicolas Stepien 2012-02-20 02:27:10 +01:00
parent fdef6b55d7
commit da843081b2
2 changed files with 43 additions and 11 deletions

View File

@ -1839,10 +1839,18 @@
return qr.message.send(post);
},
response: function(html) {
var b, err, node, persona, postNumber, reply, thread, _, _ref;
if (!(b = $('td b', $.el('a', {
var b, doc, err, node, persona, postNumber, reply, thread, _, _ref;
doc = $.el('a', {
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.';
} else if (b.childElementCount) {
if (b.firstChild.tagName) {
@ -1901,8 +1909,11 @@
return window.postMessage(data, '*');
},
receive: function(data) {
var _ref;
switch (data.req) {
var req, _ref;
req = data.req;
delete data.req;
delete data.qr;
switch (req) {
case 'abort':
if ((_ref = qr.ajax) != null) _ref.abort();
return qr.message.send({
@ -1920,7 +1931,6 @@
var boundary, callbacks, form, i, name, opts, parts, toBin, url, val;
url = "http://sys.4chan.org/" + data.board + "/post";
delete data.board;
delete data.qr;
if (engine === 'gecko' && data.upfile) {
if (!data.binary) {
toBin = function(data, name, val) {
@ -2003,7 +2013,17 @@
'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
});
}
}
}
}
};

View File

@ -1411,7 +1411,12 @@ qr =
qr.message.send post
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.'
else if b.childElementCount # error!
if b.firstChild.tagName # duplicate image link
@ -1474,7 +1479,10 @@ qr =
parent
window.postMessage data, '*'
receive: (data) ->
switch data.req
req = data.req
delete data.req
delete data.qr
switch req
when 'abort'
qr.ajax?.abort()
qr.message.send req: 'status'
@ -1490,7 +1498,6 @@ qr =
url = "http://sys.4chan.org/#{data.board}/post"
# Do not append these values to the form.
delete data.board
delete data.qr
# File with filename upload fix from desuwa
if engine is 'gecko' and data.upfile
@ -1557,7 +1564,12 @@ qr =
opts.headers =
'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 =
init: ->