Don't reload the iframe if we're banned. Don't hide the iframe, put it in the head. #243
This commit is contained in:
parent
07f6a586a5
commit
fdef6b55d7
@ -9,6 +9,7 @@
|
||||
// @include http://boards.4chan.org/*
|
||||
// @include http://images.4chan.org/*
|
||||
// @include http://sys.4chan.org/*
|
||||
// @include http://www.4chan.org/*
|
||||
// @run-at document-start
|
||||
// @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js
|
||||
// @icon http://mayhemydg.github.com/4chan-x/favicon.gif
|
||||
@ -1229,7 +1230,6 @@
|
||||
} else {
|
||||
iframe = $.el('iframe', {
|
||||
id: 'iframe',
|
||||
hidden: true,
|
||||
src: 'http://sys.4chan.org/robots.txt'
|
||||
});
|
||||
$.on(iframe, 'error', function() {
|
||||
@ -1248,7 +1248,7 @@
|
||||
return setTimeout(loadChecking, 500, this);
|
||||
}
|
||||
});
|
||||
$.add(d.body, iframe);
|
||||
$.add(d.head, iframe);
|
||||
}
|
||||
script = $.el('script', {
|
||||
textContent: 'Recaptcha.focus_response_field=function(){}'
|
||||
@ -1327,6 +1327,7 @@
|
||||
if (data == null) data = {};
|
||||
if (data.ready) {
|
||||
qr.status.ready = true;
|
||||
qr.status.banned = data.banned;
|
||||
} else if (!qr.status.ready) {
|
||||
value = 'Loading';
|
||||
disabled = true;
|
||||
@ -1335,6 +1336,9 @@
|
||||
value = 404;
|
||||
disabled = true;
|
||||
qr.cooldown.auto = false;
|
||||
} else if (qr.status.banned) {
|
||||
value = 'Banned';
|
||||
disabled = true;
|
||||
} else {
|
||||
value = qr.cooldown.seconds || data.progress || value;
|
||||
}
|
||||
@ -1893,7 +1897,7 @@
|
||||
}
|
||||
data.qr = true;
|
||||
host = location.hostname;
|
||||
window = host === 'boards.4chan.org' ? $.id('iframe').contentWindow : host === 'sys.4chan.org' ? parent : void 0;
|
||||
window = host === 'boards.4chan.org' ? $.id('iframe').contentWindow : parent;
|
||||
return window.postMessage(data, '*');
|
||||
},
|
||||
receive: function(data) {
|
||||
@ -3479,8 +3483,9 @@
|
||||
|
||||
Main = {
|
||||
init: function() {
|
||||
var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, _ref;
|
||||
pathname = location.pathname.slice(1).split('/');
|
||||
var cutoff, hiddenThreads, id, now, path, pathname, temp, timestamp, _ref;
|
||||
path = location.pathname;
|
||||
pathname = path.slice(1).split('/');
|
||||
g.BOARD = pathname[0], temp = pathname[1];
|
||||
if (temp === 'res') {
|
||||
g.REPLY = true;
|
||||
@ -3489,28 +3494,37 @@
|
||||
g.PAGENUM = parseInt(temp) || 0;
|
||||
}
|
||||
$.on(window, 'message', Main.message);
|
||||
if (location.hostname === 'sys.4chan.org') {
|
||||
if (location.pathname === '/robots.txt') {
|
||||
qr.message.send({
|
||||
req: 'status',
|
||||
ready: true
|
||||
});
|
||||
} else if (/report/.test(location.search)) {
|
||||
$.ready(function() {
|
||||
return $.on($('#recaptcha_response_field'), 'keydown', function(e) {
|
||||
if (e.keyCode === 8 && !e.target.value) {
|
||||
return window.location = 'javascript:Recaptcha.reload()';
|
||||
}
|
||||
switch (location.hostname) {
|
||||
case 'sys.4chan.org':
|
||||
if (path === '/robots.txt') {
|
||||
qr.message.send({
|
||||
req: 'status',
|
||||
ready: true
|
||||
});
|
||||
} else if (/report/.test(location.search)) {
|
||||
$.ready(function() {
|
||||
return $.on($.id('recaptcha_response_field'), 'keydown', function(e) {
|
||||
if (e.keyCode === 8 && !e.target.value) {
|
||||
return window.location = 'javascript:Recaptcha.reload()';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return;
|
||||
case 'www.4chan.org':
|
||||
if (path === '/banned') {
|
||||
qr.message.send({
|
||||
req: 'status',
|
||||
ready: true,
|
||||
banned: true
|
||||
});
|
||||
}
|
||||
return;
|
||||
case 'images.4chan.org':
|
||||
$.ready(function() {
|
||||
if (d.title === '4chan - 404') return redirect.init();
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (location.hostname === 'images.4chan.org') {
|
||||
$.ready(function() {
|
||||
if (d.title === '4chan - 404') return redirect.init();
|
||||
});
|
||||
return;
|
||||
return;
|
||||
}
|
||||
$.ready(options.init);
|
||||
now = Date.now();
|
||||
|
||||
1
Cakefile
1
Cakefile
@ -16,6 +16,7 @@ HEADER = """
|
||||
// @include http://boards.4chan.org/*
|
||||
// @include http://images.4chan.org/*
|
||||
// @include http://sys.4chan.org/*
|
||||
// @include http://www.4chan.org/*
|
||||
// @run-at document-start
|
||||
// @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js
|
||||
// @icon http://mayhemydg.github.com/4chan-x/favicon.gif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
master
|
||||
- Mayhem
|
||||
Add /vg/ archive redirection.
|
||||
Update ban support with the QR.
|
||||
Fix history issues on Chrome.
|
||||
|
||||
2.26.3
|
||||
|
||||
@ -905,7 +905,6 @@ qr =
|
||||
else
|
||||
iframe = $.el 'iframe',
|
||||
id: 'iframe'
|
||||
hidden: true
|
||||
src: 'http://sys.4chan.org/robots.txt'
|
||||
$.on iframe, 'error', -> @src = @src
|
||||
# Greasemonkey ghetto fix
|
||||
@ -914,7 +913,7 @@ qr =
|
||||
iframe.src = 'about:blank'
|
||||
setTimeout (-> iframe.src = 'http://sys.4chan.org/robots.txt'), 100
|
||||
$.on iframe, 'load', -> if @src isnt 'about:blank' then setTimeout loadChecking, 500, @
|
||||
$.add d.body, iframe
|
||||
$.add d.head, iframe
|
||||
|
||||
# Prevent original captcha input from being focused on reload.
|
||||
script = $.el 'script', textContent: 'Recaptcha.focus_response_field=function(){}'
|
||||
@ -975,7 +974,8 @@ qr =
|
||||
|
||||
status: (data={}) ->
|
||||
if data.ready
|
||||
qr.status.ready = true
|
||||
qr.status.ready = true
|
||||
qr.status.banned = data.banned
|
||||
else unless qr.status.ready
|
||||
value = 'Loading'
|
||||
disabled = true
|
||||
@ -983,6 +983,9 @@ qr =
|
||||
value = 404
|
||||
disabled = true
|
||||
qr.cooldown.auto = false
|
||||
else if qr.status.banned
|
||||
value = 'Banned'
|
||||
disabled = true
|
||||
else
|
||||
# do not cancel `value = 'Loading'` once the cooldown is over
|
||||
value = qr.cooldown.seconds or data.progress or value
|
||||
@ -1467,7 +1470,7 @@ qr =
|
||||
window =
|
||||
if host is 'boards.4chan.org'
|
||||
$.id('iframe').contentWindow
|
||||
else if host is 'sys.4chan.org'
|
||||
else
|
||||
parent
|
||||
window.postMessage data, '*'
|
||||
receive: (data) ->
|
||||
@ -2739,7 +2742,8 @@ imgExpand =
|
||||
|
||||
Main =
|
||||
init: ->
|
||||
pathname = location.pathname[1..].split '/'
|
||||
path = location.pathname
|
||||
pathname = path[1..].split '/'
|
||||
[g.BOARD, temp] = pathname
|
||||
if temp is 'res'
|
||||
g.REPLY = true
|
||||
@ -2749,17 +2753,22 @@ Main =
|
||||
|
||||
$.on window, 'message', Main.message
|
||||
|
||||
if location.hostname is 'sys.4chan.org'
|
||||
if location.pathname is '/robots.txt'
|
||||
qr.message.send req: 'status', ready: true
|
||||
else if /report/.test location.search
|
||||
$.ready ->
|
||||
$.on $('#recaptcha_response_field'), 'keydown', (e) ->
|
||||
window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value
|
||||
return
|
||||
if location.hostname is 'images.4chan.org'
|
||||
$.ready -> redirect.init() if d.title is '4chan - 404'
|
||||
return
|
||||
switch location.hostname
|
||||
when 'sys.4chan.org'
|
||||
if path is '/robots.txt'
|
||||
qr.message.send req: 'status', ready: true
|
||||
else if /report/.test location.search
|
||||
$.ready ->
|
||||
$.on $.id('recaptcha_response_field'), 'keydown', (e) ->
|
||||
window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value
|
||||
return
|
||||
when 'www.4chan.org'
|
||||
if path is '/banned'
|
||||
qr.message.send req: 'status', ready: true, banned: true
|
||||
return
|
||||
when 'images.4chan.org'
|
||||
$.ready -> redirect.init() if d.title is '4chan - 404'
|
||||
return
|
||||
|
||||
$.ready options.init
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user