From 8a17e663133eaf13793e8167e3fc02bba5697125 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 25 Jun 2012 13:47:41 +0200 Subject: [PATCH 1/2] Fix #561. --- 4chan_x.user.js | 54 ++++++++++++++++++++++++++++++++++++------------- changelog | 3 +++ script.coffee | 44 +++++++++++++++++++++++++++------------- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6b569d06d..4b8387aec 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1415,7 +1415,7 @@ QR = { init: function() { - if (!$.id('recaptcha_challenge_field_holder')) { + if (!$.id('postForm')) { return; } Main.callbacks.push(this.node); @@ -1870,9 +1870,37 @@ captcha: { init: function() { var _this = this; - this.img = $('.captcha > img', QR.el); - this.input = $('[autocomplete]', QR.el); - this.challenge = $.id('recaptcha_challenge_field_holder'); + if (!(QR.captchaIsEnabled = !!$.id('captchaFormPart'))) { + return; + } + if ($.id('recaptcha_challenge_field_holder')) { + return this.ready(); + } else { + this.onready = function() { + return _this.ready(); + }; + return $.on($.id('recaptcha_widget_div'), 'DOMNodeInserted', this.onready); + } + }, + ready: function() { + var _this = this; + if (this.challenge = $.id('recaptcha_challenge_field_holder')) { + $.off($.id('recaptcha_widget_div'), 'DOMNodeInserted', this.onready); + delete this.onready; + } else { + return; + } + $.after($('.textarea', QR.el), $.el('div', { + className: 'captchaimg', + title: 'Reload', + innerHTML: '' + })); + $.after($('.captchaimg', QR.el), $.el('div', { + className: 'captchainput', + innerHTML: '' + })); + this.img = $('.captchaimg > img', QR.el); + this.input = $('.captchainput > input', QR.el); $.on(this.img.parentNode, 'click', this.reload); $.on(this.input, 'keydown', this.keydown); $.on(this.challenge, 'DOMNodeInserted', function() { @@ -1952,9 +1980,7 @@
\
\ \ -
\ -
\ -
\ +
\
\ \
\ @@ -2062,7 +2088,7 @@ threadID = g.THREAD_ID || $('select', QR.el).value; if (!(threadID === 'new' && reply.file || threadID !== 'new' && (reply.com || reply.file))) { err = 'No file selected.'; - } else { + } else if (QR.captchaIsEnabled) { captchas = $.get('captchas', []); while ((captcha = captchas[0]) && captcha.time < Date.now()) { captchas.shift(); @@ -4392,7 +4418,7 @@ return; } $.ready(Options.init); - if (Conf['Quick Reply'] && Conf['Hide Original Post Form'] && g.BOARD !== 'f') { + if (Conf['Quick Reply'] && Conf['Hide Original Post Form']) { Main.css += '#postForm { display: none; }'; } Main.addStyle(); @@ -4738,7 +4764,7 @@ h1 {\ #qr > .move > span {\ float: right;\ }\ -#autohide, .close, #qr select, #dump, .remove, .captcha, #qr div.warning {\ +#autohide, .close, #qr select, #dump, .remove, .captchaimg, #qr div.warning {\ cursor: pointer;\ }\ #qr select,\ @@ -4895,7 +4921,7 @@ h1 {\ min-height: 120px;\ min-width: 100%;\ }\ -#qr > form > div:nth-child(3) {\ +.textarea {\ position: relative;\ }\ #charCount {\ @@ -4908,16 +4934,16 @@ h1 {\ #charCount.warning {\ color: red;\ }\ -.captcha + div > .field {\ +.captchainput > .field {\ min-width: 100%;\ }\ -.captcha {\ +.captchaimg {\ background: #FFF;\ outline: 1px solid #CCC;\ outline-offset: -1px;\ text-align: center;\ }\ -.captcha > img {\ +.captchaimg > img {\ display: block;\ height: 57px;\ width: 300px;\ diff --git a/changelog b/changelog index 8978e5495..93e2e83f7 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,7 @@ master +- Mayhem + Fix QR with the new captcha loading method. + The QR will now work on /f/ too. 2.33.3 - Mayhem diff --git a/script.coffee b/script.coffee index fff03d4b9..2b444729a 100644 --- a/script.coffee +++ b/script.coffee @@ -1045,7 +1045,7 @@ Nav = QR = init: -> - return unless $.id 'recaptcha_challenge_field_holder' + return unless $.id 'postForm' Main.callbacks.push @node setTimeout @asyncInit @@ -1389,9 +1389,27 @@ QR = captcha: init: -> - @img = $ '.captcha > img', QR.el - @input = $ '[autocomplete]', QR.el - @challenge = $.id 'recaptcha_challenge_field_holder' + return unless QR.captchaIsEnabled = !!$.id 'captchaFormPart' + if $.id 'recaptcha_challenge_field_holder' + @ready() + else + @onready = => @ready() + $.on $.id('recaptcha_widget_div'), 'DOMNodeInserted', @onready + ready: -> + if @challenge = $.id 'recaptcha_challenge_field_holder' + $.off $.id('recaptcha_widget_div'), 'DOMNodeInserted', @onready + delete @onready + else + return + $.after $('.textarea', QR.el), $.el 'div', + className: 'captchaimg' + title: 'Reload' + innerHTML: '' + $.after $('.captchaimg', QR.el), $.el 'div', + className: 'captchainput' + innerHTML: '' + @img = $ '.captchaimg > img', QR.el + @input = $ '.captchainput > input', QR.el $.on @img.parentNode, 'click', @reload $.on @input, 'keydown', @keydown $.on @challenge, 'DOMNodeInserted', => @load() @@ -1453,9 +1471,7 @@ QR =
-
-
-
+
@@ -1547,7 +1563,7 @@ QR = # prevent errors unless threadID is 'new' and reply.file or threadID isnt 'new' and (reply.com or reply.file) err = 'No file selected.' - else + else if QR.captchaIsEnabled # get oldest valid captcha captchas = $.get 'captchas', [] # remove old captchas @@ -3396,7 +3412,7 @@ Main = $.ready Options.init - if Conf['Quick Reply'] and Conf['Hide Original Post Form'] and g.BOARD isnt 'f' + if Conf['Quick Reply'] and Conf['Hide Original Post Form'] Main.css += '#postForm { display: none; }' Main.addStyle() @@ -3682,7 +3698,7 @@ h1 { #qr > .move > span { float: right; } -#autohide, .close, #qr select, #dump, .remove, .captcha, #qr div.warning { +#autohide, .close, #qr select, #dump, .remove, .captchaimg, #qr div.warning { cursor: pointer; } #qr select, @@ -3839,7 +3855,7 @@ h1 { min-height: 120px; min-width: 100%; } -#qr > form > div:nth-child(3) { +.textarea { position: relative; } #charCount { @@ -3852,16 +3868,16 @@ h1 { #charCount.warning { color: red; } -.captcha + div > .field { +.captchainput > .field { min-width: 100%; } -.captcha { +.captchaimg { background: #FFF; outline: 1px solid #CCC; outline-offset: -1px; text-align: center; } -.captcha > img { +.captchaimg > img { display: block; height: 57px; width: 300px; From 2cb60cef3f197f86f1508fded532332922c1316f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 25 Jun 2012 13:47:53 +0200 Subject: [PATCH 2/2] Release 2.33.4. --- 4chan_x.user.js | 6 +++--- Cakefile | 2 +- changelog | 2 ++ latest.js | 2 +- script.coffee | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4b8387aec..026839f3f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.33.3 +// @version 2.33.4 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -23,7 +23,7 @@ * Copyright (c) 2009-2011 James Campos * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.33.3 + * 4chan X 2.33.4 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -4716,7 +4716,7 @@ return $.globalEval(("(" + code + ")()").replace('_id_', bq.id)); }, namespace: '4chan_x.', - version: '2.33.3', + version: '2.33.4', callbacks: [], css: '\ /* dialog styling */\ diff --git a/Cakefile b/Cakefile index b7ae03f7e..b5fb8a767 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.33.3' +VERSION = '2.33.4' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index 93e2e83f7..1723e3b25 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.33.4 - Mayhem Fix QR with the new captcha loading method. The QR will now work on /f/ too. diff --git a/latest.js b/latest.js index 29c4a96cb..d8e552e0c 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.33.3'},'*') \ No newline at end of file +postMessage({version:'2.33.4'},'*') \ No newline at end of file diff --git a/script.coffee b/script.coffee index 2b444729a..dda4f90c4 100644 --- a/script.coffee +++ b/script.coffee @@ -3650,7 +3650,7 @@ Main = $.globalEval "(#{code})()".replace '_id_', bq.id namespace: '4chan_x.' - version: '2.33.3' + version: '2.33.4' callbacks: [] css: ' /* dialog styling */