From 83309cc28c1842527e0a06a50870e7ba92be7ce5 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 21 Feb 2015 11:17:29 -0800 Subject: [PATCH] Focus on checkbox when captcha is tabbed into. #250, #333 --- package.json | 1 + src/General/Main.coffee | 3 ++- src/Posting/Captcha.v2.coffee | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ef4ddf22..92300104a 100755 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "*://sys.4chan.org/*", "*://a.4cdn.org/*", "*://i.4cdn.org/*", + "https://www.google.com/recaptcha/api2/anchor?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*", "*://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc" ], "suffix": { diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 2bc10ba9b..98c16fa72 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -1,7 +1,8 @@ Main = init: -> if location.hostname is 'www.google.com' - return $.ready -> Captcha.noscript.initFrame() + type = if location.pathname is '/recaptcha/api/fallback' then 'noscript' else 'v2' + return $.ready -> Captcha[type].initFrame() g.threads = new SimpleDict() g.posts = new SimpleDict() diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index f2cb19c63..5badd46c8 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -25,6 +25,12 @@ Captcha.v2 = # XXX Greasemonkey 1.x workaround to gain access to GM_* functions. $.queueTask => @save false + initFrame: -> + $.on window, 'focus', -> + $.queueTask -> + return unless checkbox = $.id 'recaptcha-anchor' + checkbox.focus() unless d.activeElement is checkbox + shouldFocus: false timeouts: {} postsCount: 0