From 5dfd379c94c7d3c73f80f7c21318266774dd8762 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 22 Jun 2011 13:19:09 -0700 Subject: [PATCH] actually fix noscript --- 4chan_x.user.js | 13 ++++++------- script.coffee | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index cd192b759..df90cd9f4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2260,15 +2260,13 @@ }; Recaptcha = { init: function() { - var el, recaptcha, _i, _len, _ref2; + var el, _i, _len, _ref2; _ref2 = $$('#recaptcha_table a'); for (_i = 0, _len = _ref2.length; _i < _len; _i++) { el = _ref2[_i]; el.tabIndex = 1; } - if (recaptcha = $('#recaptcha_response_field')) { - return $.bind(recaptcha, 'keydown', Recaptcha.listener); - } + return $.bind($('#recaptcha_response_field'), 'keydown', Recaptcha.listener); }, listener: function(e) { if (e.keyCode === 8 && this.value === '') { @@ -2510,7 +2508,7 @@ }; main = { init: function() { - var DAY, callback, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, reply, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6; + var DAY, callback, canPost, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, reply, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6; pathname = location.pathname.substring(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { @@ -2562,7 +2560,8 @@ $.setValue('lastChecked', now); } $.addStyle(main.css); - if (form = $('form[name=post]')) { + if ((form = $('form[name=post]')) && $('#recaptcha_response_field')) { + canPost = true; Recaptcha.init(); $.bind(form, 'submit', qr.cb.submit); } @@ -2590,7 +2589,7 @@ if ($.config('Reply Hiding')) { replyHiding.init(); } - if (form && $.config('Quick Reply')) { + if (canPost && $.config('Quick Reply')) { qr.init(); } if ($.config('Report Button')) { diff --git a/script.coffee b/script.coffee index 384988481..804edcf31 100644 --- a/script.coffee +++ b/script.coffee @@ -1714,8 +1714,7 @@ Recaptcha = #hack to tab from comment straight to recaptcha for el in $$ '#recaptcha_table a' el.tabIndex = 1 - if recaptcha = $ '#recaptcha_response_field' #NoScript - $.bind recaptcha, 'keydown', Recaptcha.listener + $.bind $('#recaptcha_response_field'), 'keydown', Recaptcha.listener listener: (e) -> if e.keyCode is 8 and @value is '' # backspace to reload Recaptcha.reload() @@ -1989,7 +1988,8 @@ main = $.addStyle main.css - if form = $ 'form[name=post]' + if (form = $ 'form[name=post]') and $ '#recaptcha_response_field' + canPost = true Recaptcha.init() $.bind form, 'submit', qr.cb.submit @@ -2018,7 +2018,7 @@ main = if $.config 'Reply Hiding' replyHiding.init() - if form and $.config 'Quick Reply' + if canPost and $.config 'Quick Reply' qr.init() if $.config 'Report Button'