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