From 32878d7e2ffefe87318438a1585d91050318ba0c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:21:51 +0100 Subject: [PATCH] Fix #171. --- 4chan_x.user.js | 14 ++++++++------ script.coffee | 11 +++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e72cde4b2..2bc4a77b4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1200,7 +1200,7 @@ qr = { init: function() { - var h1, iframe; + var h1, iframe, loadChecking; if (!$.id('recaptcha_challenge_field_holder')) return; $('form[name=post]').hidden = true; h1 = $.el('h1', { @@ -1219,14 +1219,16 @@ $.on(iframe, 'error', function() { return this.src = this.src; }); - $.on(iframe, 'load', function() { - var _this = this; - if (!(qr.status.ready || this.src === 'about:blank')) { - this.src = 'about:blank'; + loadChecking = function(iframe) { + if (!qr.status.ready) { + iframe.src = 'about:blank'; return setTimeout((function() { - return _this.src = 'http://sys.4chan.org/post'; + return iframe.src = 'http://sys.4chan.org/post'; }), 250); } + }; + $.on(iframe, 'load', function() { + if (this.src !== 'about:blank') return setTimeout(loadChecking, 250, this); }); $.add(d.body, iframe); if (conf['Persistent QR']) { diff --git a/script.coffee b/script.coffee index 562cf7f5c..24ff8362f 100644 --- a/script.coffee +++ b/script.coffee @@ -869,17 +869,20 @@ qr = $.add $('.postarea'), h1 g.callbacks.push (root) -> $.on $('.quotejs + .quotejs', root), 'click', qr.quote + iframe = $.el 'iframe', id: 'iframe' hidden: true src: 'http://sys.4chan.org/post' $.on iframe, 'error', -> @src = @src # Greasemonkey ghetto fix - $.on iframe, 'load', -> - unless qr.status.ready or @src is 'about:blank' - @src = 'about:blank' - setTimeout (=> @src = 'http://sys.4chan.org/post'), 250 + loadChecking = (iframe) -> + unless qr.status.ready + iframe.src = 'about:blank' + setTimeout (-> iframe.src = 'http://sys.4chan.org/post'), 250 + $.on iframe, 'load', -> unless @src is 'about:blank' then setTimeout loadChecking, 250, @ $.add d.body, iframe + if conf['Persistent QR'] qr.dialog() qr.hide() if conf['Auto Hide QR']