diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 48d079995..f52330270 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -2,7 +2,7 @@ Main = init: -> if location.hostname is 'www.google.com' if location.pathname is '/recaptcha/api/fallback' - $.ready -> Captcha.noscript.initFrame() + $.ready -> Captcha.v2.initFrame() $.get 'Captcha Fixes', true, ({'Captcha Fixes': enabled}) -> if enabled $.ready -> Captcha.fixes.init() diff --git a/src/General/lib/connection.class b/src/General/lib/connection.class index 52e614136..00d90ae3f 100644 --- a/src/General/lib/connection.class +++ b/src/General/lib/connection.class @@ -1,5 +1,5 @@ class Connection - constructor: (@target, @origin, @cb) -> + constructor: (@target, @origin, @cb={}) -> $.on window, 'message', @onMessage send: (data) => diff --git a/src/Posting/Captcha.noscript.coffee b/src/Posting/Captcha.noscript.coffee deleted file mode 100644 index 7c330e360..000000000 --- a/src/Posting/Captcha.noscript.coffee +++ /dev/null @@ -1,20 +0,0 @@ -Captcha.noscript = - initFrame: -> - conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org", - response: (response) -> - $.id('response').value = response - $('.fbc-challenge > form').submit() - conn.send - token: $('.fbc-verification-token > textarea')?.value - error: $('.fbc-error')?.textContent - return unless img = $ '.fbc-payload > img' - cb = -> - canvas = $.el 'canvas' - canvas.width = img.width - canvas.height = img.height - canvas.getContext('2d').drawImage(img, 0, 0) - conn.send {challenge: canvas.toDataURL()} - if img.complete - cb() - else - $.on img, 'load', cb diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 242157665..3e4c7de0d 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -29,6 +29,11 @@ Captcha.v2 = # XXX Greasemonkey 1.x workaround to gain access to GM_* functions. $.queueTask => @save false + initFrame: -> + if token = $('.fbc-verification-token > textarea')?.value + conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org" + conn.send {token} + shouldFocus: false timeouts: {} postsCount: 0