From 170e1e35fb98e344d110482131be20454afc3085 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 00:35:53 -0700 Subject: [PATCH 001/130] initial commit --- 4chan_x.user.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++--- script.coffee | 50 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d9f06aa9d..ecde67147 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -57,7 +57,7 @@ */ (function() { - var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref; + var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, QR, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref; var __slice = Array.prototype.slice; config = { main: { @@ -1222,6 +1222,55 @@ } } }; + QR = { + init: function() { + var holder; + $.append(d.body, $.el('iframe', { + name: 'iframe' + })); + holder = $('#recaptcha_challenge_field_holder'); + $.bind(holder, 'DOMNodeInserted', QR.challengeNode); + QR.challengeNode({ + target: holder.firstChild + }); + return g.callbacks.push(QR.node); + }, + challengeNode: function(e) { + return QR.captcha = { + challenge: e.target.value, + time: Date.now() + }; + }, + node: function(root) { + var quote; + quote = $('a.quotejs + a', root); + return $.bind(quote, 'click', QR.quote); + }, + quote: function(e) { + e.preventDefault(); + return QR.dialog(">>" + this.textContent + "\n"); + }, + dialog: function(text) { + var l, ta; + if (text == null) { + text = ''; + } + qr.el = ui.dialog('qr', { + top: '0', + left: '0' + }, " X
Quick Reply
"); + $.bind($('form', qr.el), 'submit', QR.submit); + $.append(d.body, qr.el); + ta = $('textarea', qr.el); + l = text.length; + ta.setSelectionRange(l, l); + return ta.focus(); + }, + submit: function(e) { + $('#challenge', qr.el).value = QR.captcha.challenge; + return $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value; + } + }; qr = { init: function() { var iframe; @@ -2863,7 +2912,7 @@ replyHiding.init(); } if (conf['Quick Reply'] && canPost) { - qr.init(); + QR.init(); } if (conf['Report Button']) { reportButton.init(); @@ -3079,7 +3128,7 @@ width: 100%;\ height: 125px;\ }\ - #qr #close, #qr #autohide {\ + #qr .close, #qr #autohide {\ float: right;\ }\ #qr:not(:hover) > #autohide:checked ~ .autohide {\ diff --git a/script.coffee b/script.coffee index c9f3b6c5d..575ee91ea 100644 --- a/script.coffee +++ b/script.coffee @@ -961,6 +961,52 @@ cooldown = submit.value = 'Submit' qr.autoPost() +QR = + init: -> + $.append d.body, $.el 'iframe', + name: 'iframe' + holder = $ '#recaptcha_challenge_field_holder' + $.bind holder, 'DOMNodeInserted', QR.challengeNode + QR.challengeNode target: holder.firstChild + g.callbacks.push QR.node + challengeNode: (e) -> + QR.captcha = + challenge: e.target.value + time: Date.now() + node: (root) -> + quote = $ 'a.quotejs + a', root + $.bind quote, 'click', QR.quote + quote: (e) -> + e.preventDefault() + QR.dialog ">>#{@textContent}\n" + dialog: (text='') -> + qr.el = ui.dialog 'qr', top: '0', left: '0', " + X +
Quick Reply
+
+ + + + +
+
+
+
+
+
+
+
+ " + $.bind $('form', qr.el), 'submit', QR.submit + $.append d.body, qr.el + ta = $ 'textarea', qr.el + l = text.length + ta.setSelectionRange l, l + ta.focus() + submit: (e) -> + $('#challenge', qr.el).value = QR.captcha.challenge + $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value + qr = # TODO # error handling / logging @@ -2259,7 +2305,7 @@ main = replyHiding.init() if conf['Quick Reply'] and canPost - qr.init() + QR.init() if conf['Report Button'] reportButton.init() @@ -2462,7 +2508,7 @@ main = width: 100%; height: 125px; } - #qr #close, #qr #autohide { + #qr .close, #qr #autohide { float: right; } #qr:not(:hover) > #autohide:checked ~ .autohide { From a8273b3a9d75e23d997a59459d3947732e6f85ca Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 01:38:13 -0700 Subject: [PATCH 002/130] error notifications --- 4chan_x.user.js | 29 +++++++++++++++++++++++++++-- script.coffee | 19 ++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ecde67147..64007c6aa 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1225,6 +1225,7 @@ QR = { init: function() { var holder; + g.callbacks.push(QR.node); $.append(d.body, $.el('iframe', { name: 'iframe' })); @@ -1233,7 +1234,7 @@ QR.challengeNode({ target: holder.firstChild }); - return g.callbacks.push(QR.node); + return $.bind(window, 'message', QR.receive); }, challengeNode: function(e) { return QR.captcha = { @@ -1258,7 +1259,7 @@ qr.el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
"); + }, " X
Quick Reply
"); $.bind($('form', qr.el), 'submit', QR.submit); $.append(d.body, qr.el); ta = $('textarea', qr.el); @@ -1269,6 +1270,30 @@ submit: function(e) { $('#challenge', qr.el).value = QR.captcha.challenge; return $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value; + }, + sys: function() { + return $.globalEval(function() { + var data, href, location, node, textContent, _ref; + if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) { + textContent = node.textContent, href = node.href; + data = JSON.stringify({ + textContent: textContent, + href: href + }); + } + parent.postMessage(data, '*'); + return location = 'about:blank'; + }); + }, + receive: function(e) { + var data; + data = e.data; + if (data) { + return $.extend($('a.error', qr.el), JSON.parse(data)); + } else { + $.rm(qr.el); + return qr.el = null; + } } }; qr = { diff --git a/script.coffee b/script.coffee index 575ee91ea..0189ee23f 100644 --- a/script.coffee +++ b/script.coffee @@ -963,12 +963,13 @@ cooldown = QR = init: -> + g.callbacks.push QR.node $.append d.body, $.el 'iframe', name: 'iframe' holder = $ '#recaptcha_challenge_field_holder' $.bind holder, 'DOMNodeInserted', QR.challengeNode QR.challengeNode target: holder.firstChild - g.callbacks.push QR.node + $.bind window, 'message', QR.receive challengeNode: (e) -> QR.captcha = challenge: e.target.value @@ -996,6 +997,7 @@ QR =
+ " $.bind $('form', qr.el), 'submit', QR.submit $.append d.body, qr.el @@ -1006,6 +1008,21 @@ QR = submit: (e) -> $('#challenge', qr.el).value = QR.captcha.challenge $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value + sys: -> + $.globalEval -> + if node = document.querySelector('table font b')?.firstChild + {textContent, href} = node + data = JSON.stringify {textContent, href} + parent.postMessage data, '*' + location = 'about:blank' + + receive: (e) -> + {data} = e + if data + $.extend $('a.error', qr.el), JSON.parse data + else + $.rm qr.el + qr.el = null qr = # TODO From e440799893e51d06d9b149af2db11bf0b371464c Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 01:39:25 -0700 Subject: [PATCH 003/130] css --- 4chan_x.user.js | 5 +---- script.coffee | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 64007c6aa..ff01a9cd1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3047,12 +3047,9 @@ .error {\ color: red;\ }\ - #error {\ + #qr .error:not([href]) {\ cursor: default;\ }\ - #error[href] {\ - cursor: pointer;\ - }\ td.replyhider {\ vertical-align: top;\ }\ diff --git a/script.coffee b/script.coffee index 0189ee23f..8b09bbd45 100644 --- a/script.coffee +++ b/script.coffee @@ -2419,12 +2419,9 @@ main = .error { color: red; } - #error { + #qr .error:not([href]) { cursor: default; } - #error[href] { - cursor: pointer; - } td.replyhider { vertical-align: top; } From 1da577feadfd06539698b662b974f48da70ac5f5 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 02:10:54 -0700 Subject: [PATCH 004/130] captcha caching --- 4chan_x.user.js | 29 ++++++++++++++++++++++++++--- script.coffee | 22 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ff01a9cd1..ba0814b3c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1234,11 +1234,15 @@ QR.challengeNode({ target: holder.firstChild }); - return $.bind(window, 'message', QR.receive); + $.bind(window, 'message', QR.receive); + return $('#recaptcha_response_field').id = ''; }, challengeNode: function(e) { + var c; + c = e.target.value; + $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + c; return QR.captcha = { - challenge: e.target.value, + challenge: c, time: Date.now() }; }, @@ -1259,14 +1263,33 @@ qr.el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); $.bind($('form', qr.el), 'submit', QR.submit); + $.bind($('#recaptcha_response_field', qr.el), 'keydown', QR.keydown); $.append(d.body, qr.el); ta = $('textarea', qr.el); l = text.length; ta.setSelectionRange(l, l); return ta.focus(); }, + keydown: function(e) { + var captcha, captchas; + if (!(e.keyCode === 13 && this.value)) { + return; + } + if ($('textarea', qr.el).value || $('[type=file]', qr.el).files.length) { + return; + } + e.preventDefault(); + captcha = QR.captcha; + captcha.response = this.value; + captchas = $.get('captchas', []); + captchas.push(captcha); + $.set('captchas', captchas); + this.value = ''; + Recaptcha.reload(); + return this.nextSibling.textContent = captchas.length + ' captchas'; + }, submit: function(e) { $('#challenge', qr.el).value = QR.captcha.challenge; return $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value; diff --git a/script.coffee b/script.coffee index 8b09bbd45..2c5d8fc0e 100644 --- a/script.coffee +++ b/script.coffee @@ -970,9 +970,13 @@ QR = $.bind holder, 'DOMNodeInserted', QR.challengeNode QR.challengeNode target: holder.firstChild $.bind window, 'message', QR.receive + # nuke id so qr's field focuses on recaptcha reload, instead of normal form's + $('#recaptcha_response_field').id = '' challengeNode: (e) -> + c = e.target.value + $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" QR.captcha = - challenge: e.target.value + challenge: c time: Date.now() node: (root) -> quote = $ 'a.quotejs + a', root @@ -993,18 +997,31 @@ QR =
-
+
#{$.get('captchas', []).length} captchas
" $.bind $('form', qr.el), 'submit', QR.submit + $.bind $('#recaptcha_response_field', qr.el), 'keydown', QR.keydown $.append d.body, qr.el ta = $ 'textarea', qr.el l = text.length ta.setSelectionRange l, l ta.focus() + keydown: (e) -> + return unless e.keyCode is 13 and @value #enter, captcha filled + return if $('textarea', qr.el).value or $('[type=file]', qr.el).files.length #not blank + e.preventDefault() + {captcha} = QR + captcha.response = @value + captchas = $.get 'captchas', [] + captchas.push captcha + $.set 'captchas', captchas + @value = '' + Recaptcha.reload() + @nextSibling.textContent = captchas.length + ' captchas' submit: (e) -> $('#challenge', qr.el).value = QR.captcha.challenge $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value @@ -1015,7 +1032,6 @@ QR = data = JSON.stringify {textContent, href} parent.postMessage data, '*' location = 'about:blank' - receive: (e) -> {data} = e if data From 205883472099b215a52b478dcfe4830dc1944038 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 02:19:04 -0700 Subject: [PATCH 005/130] persist --- 4chan_x.user.js | 9 +++++---- script.coffee | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ba0814b3c..ce9573e90 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1229,13 +1229,14 @@ $.append(d.body, $.el('iframe', { name: 'iframe' })); + $.bind(window, 'message', QR.receive); + $('#recaptcha_response_field').id = ''; + QR.dialog(); holder = $('#recaptcha_challenge_field_holder'); $.bind(holder, 'DOMNodeInserted', QR.challengeNode); - QR.challengeNode({ + return QR.challengeNode({ target: holder.firstChild }); - $.bind(window, 'message', QR.receive); - return $('#recaptcha_response_field').id = ''; }, challengeNode: function(e) { var c; @@ -1263,7 +1264,7 @@ qr.el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); $.bind($('form', qr.el), 'submit', QR.submit); $.bind($('#recaptcha_response_field', qr.el), 'keydown', QR.keydown); $.append(d.body, qr.el); diff --git a/script.coffee b/script.coffee index 2c5d8fc0e..e3647adf5 100644 --- a/script.coffee +++ b/script.coffee @@ -966,12 +966,13 @@ QR = g.callbacks.push QR.node $.append d.body, $.el 'iframe', name: 'iframe' - holder = $ '#recaptcha_challenge_field_holder' - $.bind holder, 'DOMNodeInserted', QR.challengeNode - QR.challengeNode target: holder.firstChild $.bind window, 'message', QR.receive # nuke id so qr's field focuses on recaptcha reload, instead of normal form's $('#recaptcha_response_field').id = '' + QR.dialog() + holder = $ '#recaptcha_challenge_field_holder' + $.bind holder, 'DOMNodeInserted', QR.challengeNode + QR.challengeNode target: holder.firstChild challengeNode: (e) -> c = e.target.value $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" @@ -996,7 +997,7 @@ QR =
-
+
#{$.get('captchas', []).length} captchas
From 4225a7dfdfe7dbdd71525fcc89ffc345c2e13b10 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 02:28:45 -0700 Subject: [PATCH 006/130] derp, qr -> QR --- 4chan_x.user.js | 24 ++++++++++++------------ script.coffee | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ce9573e90..08bc41aa8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1241,7 +1241,7 @@ challengeNode: function(e) { var c; c = e.target.value; - $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + c; + $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=" + c; return QR.captcha = { challenge: c, time: Date.now() @@ -1261,14 +1261,14 @@ if (text == null) { text = ''; } - qr.el = ui.dialog('qr', { + QR.el = ui.dialog('qr', { top: '0', left: '0' }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); - $.bind($('form', qr.el), 'submit', QR.submit); - $.bind($('#recaptcha_response_field', qr.el), 'keydown', QR.keydown); - $.append(d.body, qr.el); - ta = $('textarea', qr.el); + $.bind($('form', QR.el), 'submit', QR.submit); + $.bind($('#recaptcha_response_field', QR.el), 'keydown', QR.keydown); + $.append(d.body, QR.el); + ta = $('textarea', QR.el); l = text.length; ta.setSelectionRange(l, l); return ta.focus(); @@ -1278,7 +1278,7 @@ if (!(e.keyCode === 13 && this.value)) { return; } - if ($('textarea', qr.el).value || $('[type=file]', qr.el).files.length) { + if ($('textarea', QR.el).value || $('[type=file]', QR.el).files.length) { return; } e.preventDefault(); @@ -1292,8 +1292,8 @@ return this.nextSibling.textContent = captchas.length + ' captchas'; }, submit: function(e) { - $('#challenge', qr.el).value = QR.captcha.challenge; - return $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value; + $('#challenge', QR.el).value = QR.captcha.challenge; + return $('#response', QR.el).value = $('#recaptcha_response_field', QR.el).value; }, sys: function() { return $.globalEval(function() { @@ -1313,10 +1313,10 @@ var data; data = e.data; if (data) { - return $.extend($('a.error', qr.el), JSON.parse(data)); + return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - $.rm(qr.el); - return qr.el = null; + $.rm(QR.el); + return QR.el = null; } } }; diff --git a/script.coffee b/script.coffee index e3647adf5..bfc97d2ef 100644 --- a/script.coffee +++ b/script.coffee @@ -975,7 +975,7 @@ QR = QR.challengeNode target: holder.firstChild challengeNode: (e) -> c = e.target.value - $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" + $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" QR.captcha = challenge: c time: Date.now() @@ -986,7 +986,7 @@ QR = e.preventDefault() QR.dialog ">>#{@textContent}\n" dialog: (text='') -> - qr.el = ui.dialog 'qr', top: '0', left: '0', " + QR.el = ui.dialog 'qr', top: '0', left: '0', " X
Quick Reply
@@ -1004,16 +1004,16 @@ QR =
" - $.bind $('form', qr.el), 'submit', QR.submit - $.bind $('#recaptcha_response_field', qr.el), 'keydown', QR.keydown - $.append d.body, qr.el - ta = $ 'textarea', qr.el + $.bind $('form', QR.el), 'submit', QR.submit + $.bind $('#recaptcha_response_field', QR.el), 'keydown', QR.keydown + $.append d.body, QR.el + ta = $ 'textarea', QR.el l = text.length ta.setSelectionRange l, l ta.focus() keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled - return if $('textarea', qr.el).value or $('[type=file]', qr.el).files.length #not blank + return if $('textarea', QR.el).value or $('[type=file]', QR.el).files.length #not blank e.preventDefault() {captcha} = QR captcha.response = @value @@ -1024,8 +1024,8 @@ QR = Recaptcha.reload() @nextSibling.textContent = captchas.length + ' captchas' submit: (e) -> - $('#challenge', qr.el).value = QR.captcha.challenge - $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value + $('#challenge', QR.el).value = QR.captcha.challenge + $('#response', QR.el).value = $('#recaptcha_response_field', QR.el).value sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild @@ -1036,10 +1036,10 @@ QR = receive: (e) -> {data} = e if data - $.extend $('a.error', qr.el), JSON.parse data + $.extend $('a.error', QR.el), JSON.parse data else - $.rm qr.el - qr.el = null + $.rm QR.el + QR.el = null qr = # TODO From dfd226bd64edafca9f9220170ca376061af14884 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 02:42:01 -0700 Subject: [PATCH 007/130] insert text at cursor --- 4chan_x.user.js | 14 +++++++++++++- script.coffee | 12 +++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 08bc41aa8..6d48387c7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1253,8 +1253,20 @@ return $.bind(quote, 'click', QR.quote); }, quote: function(e) { + var i, ss, ta, text, v; e.preventDefault(); - return QR.dialog(">>" + this.textContent + "\n"); + text = ">>" + this.textContent + "\n"; + if (!QR.el) { + QR.dialog(text); + return; + } + ta = $('textarea', QR.el); + v = ta.value; + ss = ta.selectionStart; + ta.value = v.slice(0, ss) + text + v.slice(ss); + i = ss + text.length; + ta.setSelectionRange(i, i); + return ta.focus(); }, dialog: function(text) { var l, ta; diff --git a/script.coffee b/script.coffee index bfc97d2ef..c253856dc 100644 --- a/script.coffee +++ b/script.coffee @@ -984,7 +984,17 @@ QR = $.bind quote, 'click', QR.quote quote: (e) -> e.preventDefault() - QR.dialog ">>#{@textContent}\n" + text = ">>#{@textContent}\n" + if not QR.el + QR.dialog text + return + ta = $ 'textarea', QR.el + v = ta.value + ss = ta.selectionStart + ta.value = v[0...ss] + text + v[ss..] + i = ss + text.length + ta.setSelectionRange i, i + ta.focus() dialog: (text='') -> QR.el = ui.dialog 'qr', top: '0', left: '0', " X From cf386d0e72783db345fab66bae7bc3deedaf7bbe Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 21:54:12 -0700 Subject: [PATCH 008/130] autohiding --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c76ddcb7d..36b99364a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3191,7 +3191,7 @@ #qr .close, #qr #autohide {\ float: right;\ }\ - #qr:not(:hover) > #autohide:checked ~ .autohide {\ + #qr:not(:hover) > #autohide:checked ~ form {\ height: 0;\ overflow: hidden;\ }\ diff --git a/script.coffee b/script.coffee index 90cdee96a..2bc2fff48 100644 --- a/script.coffee +++ b/script.coffee @@ -2552,7 +2552,7 @@ main = #qr .close, #qr #autohide { float: right; } - #qr:not(:hover) > #autohide:checked ~ .autohide { + #qr:not(:hover) > #autohide:checked ~ form { height: 0; overflow: hidden; } From 7f1618f977474f2d0c1474a17f82a1e2b789de30 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 1 Sep 2011 21:56:36 -0700 Subject: [PATCH 009/130] clear error on submit --- 4chan_x.user.js | 1 + script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 36b99364a..0dcfaaf35 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1306,6 +1306,7 @@ return this.nextSibling.textContent = captchas.length + ' captchas'; }, submit: function(e) { + $('.error', qr.el).textContent = ''; $('#challenge', QR.el).value = QR.captcha.challenge; return $('#response', QR.el).value = $('#recaptcha_response_field', QR.el).value; }, diff --git a/script.coffee b/script.coffee index 2bc2fff48..94bc4ccd1 100644 --- a/script.coffee +++ b/script.coffee @@ -1034,6 +1034,7 @@ QR = Recaptcha.reload() @nextSibling.textContent = captchas.length + ' captchas' submit: (e) -> + $('.error', qr.el).textContent = '' $('#challenge', QR.el).value = QR.captcha.challenge $('#response', QR.el).value = $('#recaptcha_response_field', QR.el).value sys: -> From 8496654e65f0615a3bf45e1e97210ff21a85b37b Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 00:22:51 -0700 Subject: [PATCH 010/130] use captchas --- 4chan_x.user.js | 37 +++++++++++++++++++++++++++++++------ script.coffee | 27 ++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0dcfaaf35..e7d2174ac 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1288,7 +1288,6 @@ return ta.focus(); }, keydown: function(e) { - var captcha, captchas; if (!(e.keyCode === 13 && this.value)) { return; } @@ -1296,19 +1295,45 @@ return; } e.preventDefault(); + return QR.captchaPush(this); + }, + captchaPush: function(el) { + var captcha, captchas; captcha = QR.captcha; - captcha.response = this.value; + captcha.response = el.value; captchas = $.get('captchas', []); captchas.push(captcha); $.set('captchas', captchas); - this.value = ''; + el.value = ''; Recaptcha.reload(); - return this.nextSibling.textContent = captchas.length + ' captchas'; + return el.nextSibling.textContent = captchas.length + ' captchas'; + }, + captchaShift: function() { + var captcha, captchas, cutoff; + captchas = $.get('captchas', []); + cutoff = Date.now() - 5 * HOUR + 5 * MINUTE; + while (captcha = captchas.shift()) { + if (captcha.time > cutoff) { + break; + } + } + $.set('captchas', captchas); + return captcha; }, submit: function(e) { + var captcha, challenge, el, response; $('.error', qr.el).textContent = ''; - $('#challenge', QR.el).value = QR.captcha.challenge; - return $('#response', QR.el).value = $('#recaptcha_response_field', QR.el).value; + if ((el = $('#recaptcha_response_field', QR.el)).value) { + QR.captchaPush(el); + } + if (!(captcha = captchaShift())) { + alert('You forgot to type in the verification.'); + e.preventDefault(); + return; + } + challenge = captcha.challenge, response = captcha.response; + $('#challenge', QR.el).value = challenge; + return $('#response', QR.el).value = response; }, sys: function() { return $.globalEval(function() { diff --git a/script.coffee b/script.coffee index 94bc4ccd1..88a9fccf0 100644 --- a/script.coffee +++ b/script.coffee @@ -1025,18 +1025,35 @@ QR = return unless e.keyCode is 13 and @value #enter, captcha filled return if $('textarea', QR.el).value or $('[type=file]', QR.el).files.length #not blank e.preventDefault() + QR.captchaPush @ + captchaPush: (el) -> {captcha} = QR - captcha.response = @value + captcha.response = el.value captchas = $.get 'captchas', [] captchas.push captcha $.set 'captchas', captchas - @value = '' + el.value = '' Recaptcha.reload() - @nextSibling.textContent = captchas.length + ' captchas' + el.nextSibling.textContent = captchas.length + ' captchas' + captchaShift: -> + captchas = $.get 'captchas', [] + cutoff = Date.now() - 5*HOUR + 5*MINUTE + while captcha = captchas.shift() + if captcha.time > cutoff + break + $.set 'captchas', captchas + captcha submit: (e) -> $('.error', qr.el).textContent = '' - $('#challenge', QR.el).value = QR.captcha.challenge - $('#response', QR.el).value = $('#recaptcha_response_field', QR.el).value + if (el = $('#recaptcha_response_field', QR.el)).value + QR.captchaPush el + if not captcha = captchaShift() + alert 'You forgot to type in the verification.' + e.preventDefault() + return + {challenge, response} = captcha + $('#challenge', QR.el).value = challenge + $('#response', QR.el).value = response sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild From 9ca7ef0ef0ef66f3c2b6dd4853357e675998113c Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 00:30:28 -0700 Subject: [PATCH 011/130] -persist --- 4chan_x.user.js | 3 +-- script.coffee | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e7d2174ac..b2508c75e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1233,7 +1233,6 @@ })); $.bind(window, 'message', QR.receive); $('#recaptcha_response_field').id = ''; - QR.dialog(); holder = $('#recaptcha_challenge_field_holder'); $.bind(holder, 'DOMNodeInserted', QR.challengeNode); return QR.challengeNode({ @@ -1278,7 +1277,7 @@ QR.el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); $.bind($('form', QR.el), 'submit', QR.submit); $.bind($('#recaptcha_response_field', QR.el), 'keydown', QR.keydown); $.append(d.body, QR.el); diff --git a/script.coffee b/script.coffee index 88a9fccf0..2088da3be 100644 --- a/script.coffee +++ b/script.coffee @@ -969,7 +969,6 @@ QR = $.bind window, 'message', QR.receive # nuke id so qr's field focuses on recaptcha reload, instead of normal form's $('#recaptcha_response_field').id = '' - QR.dialog() holder = $ '#recaptcha_challenge_field_holder' $.bind holder, 'DOMNodeInserted', QR.challengeNode QR.challengeNode target: holder.firstChild @@ -1007,7 +1006,7 @@ QR =
-
+
#{$.get('captchas', []).length} captchas
From b2f92437153417ef3549032810c338ca7dbbe810 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 00:34:30 -0700 Subject: [PATCH 012/130] QR.close, QR.el = el --- 4chan_x.user.js | 20 ++++++++++++-------- script.coffee | 17 ++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b2508c75e..d163d9eac 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1269,19 +1269,24 @@ ta.setSelectionRange(i, i); return ta.focus(); }, + close: function() { + $.rm(QR.el); + return QR.el = null; + }, dialog: function(text) { - var l, ta; + var el, l, ta; if (text == null) { text = ''; } - QR.el = ui.dialog('qr', { + QR.el = el = ui.dialog('qr', { top: '0', left: '0' }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); - $.bind($('form', QR.el), 'submit', QR.submit); - $.bind($('#recaptcha_response_field', QR.el), 'keydown', QR.keydown); - $.append(d.body, QR.el); - ta = $('textarea', QR.el); + $.bind($('.close', el), 'click', QR.close); + $.bind($('form', el), 'submit', QR.submit); + $.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown); + $.append(d.body, el); + ta = $('textarea', el); l = text.length; ta.setSelectionRange(l, l); return ta.focus(); @@ -1354,8 +1359,7 @@ if (data) { return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - $.rm(QR.el); - return QR.el = null; + return QR.close(); } } }; diff --git a/script.coffee b/script.coffee index 2088da3be..f495e6af2 100644 --- a/script.coffee +++ b/script.coffee @@ -994,8 +994,11 @@ QR = i = ss + text.length ta.setSelectionRange i, i ta.focus() + close: -> + $.rm QR.el + QR.el = null dialog: (text='') -> - QR.el = ui.dialog 'qr', top: '0', left: '0', " + QR.el = el = ui.dialog 'qr', top: '0', left: '0', " X
Quick Reply
@@ -1013,10 +1016,11 @@ QR =
" - $.bind $('form', QR.el), 'submit', QR.submit - $.bind $('#recaptcha_response_field', QR.el), 'keydown', QR.keydown - $.append d.body, QR.el - ta = $ 'textarea', QR.el + $.bind $('.close', el), 'click', QR.close + $.bind $('form', el), 'submit', QR.submit + $.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown + $.append d.body, el + ta = $ 'textarea', el l = text.length ta.setSelectionRange l, l ta.focus() @@ -1065,8 +1069,7 @@ QR = if data $.extend $('a.error', QR.el), JSON.parse data else - $.rm QR.el - QR.el = null + QR.close() qr = # TODO From f3366e0a8a9621b9322ee7bafc3a3f47ea1a1e4b Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 00:36:29 -0700 Subject: [PATCH 013/130] challengeNode -> captchaNode --- 4chan_x.user.js | 6 +++--- script.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d163d9eac..5387bb5c1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1234,12 +1234,12 @@ $.bind(window, 'message', QR.receive); $('#recaptcha_response_field').id = ''; holder = $('#recaptcha_challenge_field_holder'); - $.bind(holder, 'DOMNodeInserted', QR.challengeNode); - return QR.challengeNode({ + $.bind(holder, 'DOMNodeInserted', QR.captchaNode); + return QR.captchaNode({ target: holder.firstChild }); }, - challengeNode: function(e) { + captchaNode: function(e) { var c; c = e.target.value; $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=" + c; diff --git a/script.coffee b/script.coffee index f495e6af2..e5e159824 100644 --- a/script.coffee +++ b/script.coffee @@ -970,9 +970,9 @@ QR = # nuke id so qr's field focuses on recaptcha reload, instead of normal form's $('#recaptcha_response_field').id = '' holder = $ '#recaptcha_challenge_field_holder' - $.bind holder, 'DOMNodeInserted', QR.challengeNode - QR.challengeNode target: holder.firstChild - challengeNode: (e) -> + $.bind holder, 'DOMNodeInserted', QR.captchaNode + QR.captchaNode target: holder.firstChild + captchaNode: (e) -> c = e.target.value $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" QR.captcha = From 288fede1caf865cfb68634c4fc23d7c275df04d1 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 00:37:51 -0700 Subject: [PATCH 014/130] shuffle --- 4chan_x.user.js | 96 ++++++++++++++++++++++++------------------------- script.coffee | 78 ++++++++++++++++++++-------------------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5387bb5c1..dea3b5598 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1248,31 +1248,38 @@ time: Date.now() }; }, - node: function(root) { - var quote; - quote = $('a.quotejs + a', root); - return $.bind(quote, 'click', QR.quote); + captchaPush: function(el) { + var captcha, captchas; + captcha = QR.captcha; + captcha.response = el.value; + captchas = $.get('captchas', []); + captchas.push(captcha); + $.set('captchas', captchas); + el.value = ''; + Recaptcha.reload(); + return el.nextSibling.textContent = captchas.length + ' captchas'; }, - quote: function(e) { - var i, ss, ta, text, v; - e.preventDefault(); - text = ">>" + this.textContent + "\n"; - if (!QR.el) { - QR.dialog(text); - return; + captchaShift: function() { + var captcha, captchas, cutoff; + captchas = $.get('captchas', []); + cutoff = Date.now() - 5 * HOUR + 5 * MINUTE; + while (captcha = captchas.shift()) { + if (captcha.time > cutoff) { + break; + } } - ta = $('textarea', QR.el); - v = ta.value; - ss = ta.selectionStart; - ta.value = v.slice(0, ss) + text + v.slice(ss); - i = ss + text.length; - ta.setSelectionRange(i, i); - return ta.focus(); + $.set('captchas', captchas); + return captcha; }, close: function() { $.rm(QR.el); return QR.el = null; }, + node: function(root) { + var quote; + quote = $('a.quotejs + a', root); + return $.bind(quote, 'click', QR.quote); + }, dialog: function(text) { var el, l, ta; if (text == null) { @@ -1301,28 +1308,30 @@ e.preventDefault(); return QR.captchaPush(this); }, - captchaPush: function(el) { - var captcha, captchas; - captcha = QR.captcha; - captcha.response = el.value; - captchas = $.get('captchas', []); - captchas.push(captcha); - $.set('captchas', captchas); - el.value = ''; - Recaptcha.reload(); - return el.nextSibling.textContent = captchas.length + ' captchas'; - }, - captchaShift: function() { - var captcha, captchas, cutoff; - captchas = $.get('captchas', []); - cutoff = Date.now() - 5 * HOUR + 5 * MINUTE; - while (captcha = captchas.shift()) { - if (captcha.time > cutoff) { - break; - } + quote: function(e) { + var i, ss, ta, text, v; + e.preventDefault(); + text = ">>" + this.textContent + "\n"; + if (!QR.el) { + QR.dialog(text); + return; + } + ta = $('textarea', QR.el); + v = ta.value; + ss = ta.selectionStart; + ta.value = v.slice(0, ss) + text + v.slice(ss); + i = ss + text.length; + ta.setSelectionRange(i, i); + return ta.focus(); + }, + receive: function(e) { + var data; + data = e.data; + if (data) { + return $.extend($('a.error', QR.el), JSON.parse(data)); + } else { + return QR.close(); } - $.set('captchas', captchas); - return captcha; }, submit: function(e) { var captcha, challenge, el, response; @@ -1352,15 +1361,6 @@ parent.postMessage(data, '*'); return location = 'about:blank'; }); - }, - receive: function(e) { - var data; - data = e.data; - if (data) { - return $.extend($('a.error', QR.el), JSON.parse(data)); - } else { - return QR.close(); - } } }; qr = { diff --git a/script.coffee b/script.coffee index e5e159824..f912349ad 100644 --- a/script.coffee +++ b/script.coffee @@ -978,25 +978,29 @@ QR = QR.captcha = challenge: c time: Date.now() - node: (root) -> - quote = $ 'a.quotejs + a', root - $.bind quote, 'click', QR.quote - quote: (e) -> - e.preventDefault() - text = ">>#{@textContent}\n" - if not QR.el - QR.dialog text - return - ta = $ 'textarea', QR.el - v = ta.value - ss = ta.selectionStart - ta.value = v[0...ss] + text + v[ss..] - i = ss + text.length - ta.setSelectionRange i, i - ta.focus() + captchaPush: (el) -> + {captcha} = QR + captcha.response = el.value + captchas = $.get 'captchas', [] + captchas.push captcha + $.set 'captchas', captchas + el.value = '' + Recaptcha.reload() + el.nextSibling.textContent = captchas.length + ' captchas' + captchaShift: -> + captchas = $.get 'captchas', [] + cutoff = Date.now() - 5*HOUR + 5*MINUTE + while captcha = captchas.shift() + if captcha.time > cutoff + break + $.set 'captchas', captchas + captcha close: -> $.rm QR.el QR.el = null + node: (root) -> + quote = $ 'a.quotejs + a', root + $.bind quote, 'click', QR.quote dialog: (text='') -> QR.el = el = ui.dialog 'qr', top: '0', left: '0', " X @@ -1029,23 +1033,25 @@ QR = return if $('textarea', QR.el).value or $('[type=file]', QR.el).files.length #not blank e.preventDefault() QR.captchaPush @ - captchaPush: (el) -> - {captcha} = QR - captcha.response = el.value - captchas = $.get 'captchas', [] - captchas.push captcha - $.set 'captchas', captchas - el.value = '' - Recaptcha.reload() - el.nextSibling.textContent = captchas.length + ' captchas' - captchaShift: -> - captchas = $.get 'captchas', [] - cutoff = Date.now() - 5*HOUR + 5*MINUTE - while captcha = captchas.shift() - if captcha.time > cutoff - break - $.set 'captchas', captchas - captcha + quote: (e) -> + e.preventDefault() + text = ">>#{@textContent}\n" + if not QR.el + QR.dialog text + return + ta = $ 'textarea', QR.el + v = ta.value + ss = ta.selectionStart + ta.value = v[0...ss] + text + v[ss..] + i = ss + text.length + ta.setSelectionRange i, i + ta.focus() + receive: (e) -> + {data} = e + if data + $.extend $('a.error', QR.el), JSON.parse data + else + QR.close() submit: (e) -> $('.error', qr.el).textContent = '' if (el = $('#recaptcha_response_field', QR.el)).value @@ -1064,12 +1070,6 @@ QR = data = JSON.stringify {textContent, href} parent.postMessage data, '*' location = 'about:blank' - receive: (e) -> - {data} = e - if data - $.extend $('a.error', QR.el), JSON.parse data - else - QR.close() qr = # TODO From e5239d8947cbe17f79dc63d64c33114e6cff670f Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 00:39:03 -0700 Subject: [PATCH 015/130] merge QR.node into QR.init --- 4chan_x.user.js | 11 +++++------ script.coffee | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index dea3b5598..eec097668 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1227,7 +1227,11 @@ QR = { init: function() { var holder; - g.callbacks.push(QR.node); + g.callbacks.push(function(root) { + var quote; + quote = $('a.quotejs + a', root); + return $.bind(quote, 'click', QR.quote); + }); $.append(d.body, $.el('iframe', { name: 'iframe' })); @@ -1275,11 +1279,6 @@ $.rm(QR.el); return QR.el = null; }, - node: function(root) { - var quote; - quote = $('a.quotejs + a', root); - return $.bind(quote, 'click', QR.quote); - }, dialog: function(text) { var el, l, ta; if (text == null) { diff --git a/script.coffee b/script.coffee index f912349ad..5425068be 100644 --- a/script.coffee +++ b/script.coffee @@ -963,7 +963,9 @@ cooldown = QR = init: -> - g.callbacks.push QR.node + g.callbacks.push (root) -> + quote = $ 'a.quotejs + a', root + $.bind quote, 'click', QR.quote $.append d.body, $.el 'iframe', name: 'iframe' $.bind window, 'message', QR.receive @@ -998,9 +1000,6 @@ QR = close: -> $.rm QR.el QR.el = null - node: (root) -> - quote = $ 'a.quotejs + a', root - $.bind quote, 'click', QR.quote dialog: (text='') -> QR.el = el = ui.dialog 'qr', top: '0', left: '0', " X From 0b9b948f1d64fc74b8a36bdeda77d98d11b1a38d Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 18:29:11 -0700 Subject: [PATCH 016/130] derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ac78a73ab..9c02de00e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1338,7 +1338,7 @@ if ((el = $('#recaptcha_response_field', QR.el)).value) { QR.captchaPush(el); } - if (!(captcha = captchaShift())) { + if (!(captcha = QR.captchaShift())) { alert('You forgot to type in the verification.'); e.preventDefault(); return; diff --git a/script.coffee b/script.coffee index a52ccaef1..1aef56b56 100644 --- a/script.coffee +++ b/script.coffee @@ -1055,7 +1055,7 @@ QR = $('.error', qr.el).textContent = '' if (el = $('#recaptcha_response_field', QR.el)).value QR.captchaPush el - if not captcha = captchaShift() + if not captcha = QR.captchaShift() alert 'You forgot to type in the verification.' e.preventDefault() return From 71075d4c12d8cad26144d1c48af9367a4f8eb169 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 18:54:54 -0700 Subject: [PATCH 017/130] derp --- 4chan_x.user.js | 6 +++--- script.coffee | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9c02de00e..afb84620d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1349,7 +1349,7 @@ }, sys: function() { return $.globalEval(function() { - var data, href, location, node, textContent, _ref; + var data, href, node, textContent, _ref; if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) { textContent = node.textContent, href = node.href; data = JSON.stringify({ @@ -1358,7 +1358,7 @@ }); } parent.postMessage(data, '*'); - return location = 'about:blank'; + return window.location = 'about:blank'; }); } }; @@ -2919,7 +2919,7 @@ g.PAGENUM = parseInt(temp) || 0; } if (location.hostname === 'sys.4chan.org') { - qr.sys(); + QR.sys(); return; } if (conf['404 Redirect'] && d.title === '4chan - 404' && /^\d+$/.test(g.THREAD_ID)) { diff --git a/script.coffee b/script.coffee index 1aef56b56..f60468d3d 100644 --- a/script.coffee +++ b/script.coffee @@ -1068,7 +1068,7 @@ QR = {textContent, href} = node data = JSON.stringify {textContent, href} parent.postMessage data, '*' - location = 'about:blank' + window.location = 'about:blank' qr = # TODO @@ -2288,7 +2288,7 @@ main = g.PAGENUM = parseInt(temp) or 0 if location.hostname is 'sys.4chan.org' - qr.sys() + QR.sys() return if conf['404 Redirect'] and d.title is '4chan - 404' and /^\d+$/.test g.THREAD_ID redirect() From 4ec8ca541ebef32ae464acf6640c1bdef11afee7 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 19:55:22 -0700 Subject: [PATCH 018/130] cooldown --- 4chan_x.user.js | 32 +++++++++++++++++++++++++++++++- script.coffee | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index afb84620d..d4a25773d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1288,6 +1288,9 @@ top: '0', left: '0' }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + if (conf['Cooldown']) { + QR.cooldown; + } $.bind($('.close', el), 'click', QR.close); $.bind($('form', el), 'submit', QR.submit); $.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown); @@ -1323,13 +1326,40 @@ ta.setSelectionRange(i, i); return ta.focus(); }, + cooldown: function() { + var b, n, now; + if (!QR.el) { + return; + } + cooldown = $.get("cooldown/" + g.BOARD, 0); + now = Date.now(); + n = Math.ceil((cooldown - now) / 1000); + b = $('button', QR.el); + if (n > 0) { + setTimeout(QR.cooldown, 1000); + return $.extend(b, { + textContent: n, + disabled: true + }); + } else { + return $.extend(b, { + textContent: 'Submit', + disabled: false + }); + } + }, receive: function(e) { var data; data = e.data; if (data) { return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - return QR.close(); + QR.close(); + if (conf['Cooldown']) { + cooldown = Date.now() + 30 * SECOND; + $.set("cooldown/" + g.BOARD, cooldown); + return QR.cooldown(); + } } }, submit: function(e) { diff --git a/script.coffee b/script.coffee index f60468d3d..eec34ceb5 100644 --- a/script.coffee +++ b/script.coffee @@ -1019,6 +1019,7 @@ QR = " + QR.cooldown if conf['Cooldown'] $.bind $('.close', el), 'click', QR.close $.bind $('form', el), 'submit', QR.submit $.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown @@ -1045,12 +1046,31 @@ QR = i = ss + text.length ta.setSelectionRange i, i ta.focus() + cooldown: -> + return unless QR.el + cooldown = $.get "cooldown/#{g.BOARD}", 0 + now = Date.now() + n = Math.ceil (cooldown - now) / 1000 + b = $ 'button', QR.el + if n > 0 + setTimeout QR.cooldown, 1000 + $.extend b, + textContent: n + disabled: true + else + $.extend b, + textContent: 'Submit' + disabled: false receive: (e) -> {data} = e if data $.extend $('a.error', QR.el), JSON.parse data else QR.close() + if conf['Cooldown'] + cooldown = Date.now() + 30*SECOND + $.set "cooldown/#{g.BOARD}", cooldown + QR.cooldown() submit: (e) -> $('.error', qr.el).textContent = '' if (el = $('#recaptcha_response_field', QR.el)).value From 574b2fe2fb93f2c521e11d188c4405ed5cc9d5c6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:01:19 -0700 Subject: [PATCH 019/130] auto hide, persist --- 4chan_x.user.js | 23 ++++++++++++++--------- script.coffee | 12 ++++++------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d4a25773d..8d1d4bdd4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1239,9 +1239,15 @@ $('#recaptcha_response_field').id = ''; holder = $('#recaptcha_challenge_field_holder'); $.bind(holder, 'DOMNodeInserted', QR.captchaNode); - return QR.captchaNode({ + QR.captchaNode({ target: holder.firstChild }); + if (conf['Persistent QR']) { + qr.dialog(); + if (conf['Auto Hide QR']) { + return $('#autohide', QR.el).checked = true; + } + } }, captchaNode: function(e) { var c; @@ -1354,7 +1360,9 @@ if (data) { return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - QR.close(); + if (!conf['Persistent QR']) { + QR.close(); + } if (conf['Cooldown']) { cooldown = Date.now() + 30 * SECOND; $.set("cooldown/" + g.BOARD, cooldown); @@ -1375,7 +1383,10 @@ } challenge = captcha.challenge, response = captcha.response; $('#challenge', QR.el).value = challenge; - return $('#response', QR.el).value = response; + $('#response', QR.el).value = response; + if (conf['Auto Hide QR']) { + return $('#autohide', QR.el).checked = true; + } }, sys: function() { return $.globalEval(function() { @@ -3065,12 +3076,6 @@ if (conf['Image Preloading']) { imgPreloading.init(); } - if (conf['Quick Reply'] && conf['Persistent QR'] && canPost) { - qr.dialog(); - if (conf['Auto Hide QR']) { - $('#autohide', qr.el).checked = true; - } - } if (conf['Post in Title']) { titlePost.init(); } diff --git a/script.coffee b/script.coffee index eec34ceb5..6cf1d2cd8 100644 --- a/script.coffee +++ b/script.coffee @@ -974,6 +974,10 @@ QR = holder = $ '#recaptcha_challenge_field_holder' $.bind holder, 'DOMNodeInserted', QR.captchaNode QR.captchaNode target: holder.firstChild + if conf['Persistent QR'] + qr.dialog() + if conf['Auto Hide QR'] + $('#autohide', QR.el).checked = true captchaNode: (e) -> c = e.target.value $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" @@ -1066,7 +1070,7 @@ QR = if data $.extend $('a.error', QR.el), JSON.parse data else - QR.close() + QR.close() unless conf['Persistent QR'] if conf['Cooldown'] cooldown = Date.now() + 30*SECOND $.set "cooldown/#{g.BOARD}", cooldown @@ -1082,6 +1086,7 @@ QR = {challenge, response} = captcha $('#challenge', QR.el).value = challenge $('#response', QR.el).value = response + $('#autohide', QR.el).checked = true if conf['Auto Hide QR'] sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild @@ -2420,11 +2425,6 @@ main = if conf['Image Preloading'] imgPreloading.init() - if conf['Quick Reply'] and conf['Persistent QR'] and canPost - qr.dialog() - if conf['Auto Hide QR'] - $('#autohide', qr.el).checked = true - if conf['Post in Title'] titlePost.init() From 280d8b3d52b20d2e0d9bbcf92f84f75af32bf89a Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:02:08 -0700 Subject: [PATCH 020/130] hidden iframe --- 4chan_x.user.js | 3 ++- script.coffee | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8d1d4bdd4..8c1e9f361 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1233,7 +1233,8 @@ return $.bind(quote, 'click', QR.quote); }); $.append(d.body, $.el('iframe', { - name: 'iframe' + name: 'iframe', + hidden: true })); $.bind(window, 'message', QR.receive); $('#recaptcha_response_field').id = ''; diff --git a/script.coffee b/script.coffee index 6cf1d2cd8..c48814327 100644 --- a/script.coffee +++ b/script.coffee @@ -968,6 +968,7 @@ QR = $.bind quote, 'click', QR.quote $.append d.body, $.el 'iframe', name: 'iframe' + hidden: true $.bind window, 'message', QR.receive # nuke id so qr's field focuses on recaptcha reload, instead of normal form's $('#recaptcha_response_field').id = '' From b29ea64bc3aadd347451328180e2754b10a907f3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:17:07 -0700 Subject: [PATCH 021/130] auto post --- 4chan_x.user.js | 31 ++++++++++++++++++++++++------- script.coffee | 16 ++++++++++++---- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8c1e9f361..61b434104 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1294,7 +1294,7 @@ QR.el = el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); if (conf['Cooldown']) { QR.cooldown; } @@ -1307,11 +1307,20 @@ ta.setSelectionRange(l, l); return ta.focus(); }, + hasContent: function() { + return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length; + }, + autoPost: function() { + if (!QR.hasContent()) { + return; + } + return QR.submit(); + }, keydown: function(e) { if (!(e.keyCode === 13 && this.value)) { return; } - if ($('textarea', QR.el).value || $('[type=file]', QR.el).files.length) { + if (QR.hasContent()) { return; } e.preventDefault(); @@ -1343,16 +1352,19 @@ n = Math.ceil((cooldown - now) / 1000); b = $('button', QR.el); if (n > 0) { - setTimeout(QR.cooldown, 1000); - return $.extend(b, { + $.extend(b, { textContent: n, disabled: true }); + return setTimeout(QR.cooldown, 1000); } else { - return $.extend(b, { + $.extend(b, { textContent: 'Submit', disabled: false }); + if ($('#auto', QR.el).checked) { + return QR.autoPost(); + } } }, receive: function(e) { @@ -1379,14 +1391,19 @@ } if (!(captcha = QR.captchaShift())) { alert('You forgot to type in the verification.'); - e.preventDefault(); + if (e != null) { + e.preventDefault(); + } return; } challenge = captcha.challenge, response = captcha.response; $('#challenge', QR.el).value = challenge; $('#response', QR.el).value = response; if (conf['Auto Hide QR']) { - return $('#autohide', QR.el).checked = true; + $('#autohide', QR.el).checked = true; + } + if (!e) { + return $('#qr_form', QR.el).submit; } }, sys: function() { diff --git a/script.coffee b/script.coffee index c48814327..7f948754e 100644 --- a/script.coffee +++ b/script.coffee @@ -1015,7 +1015,7 @@ QR =
-
+
#{$.get('captchas', []).length} captchas
@@ -1033,9 +1033,14 @@ QR = l = text.length ta.setSelectionRange l, l ta.focus() + hasContent: -> + $('textarea', QR.el).value or $('[type=file]', QR.el).files.length + autoPost: -> + return unless QR.hasContent() + QR.submit() keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled - return if $('textarea', QR.el).value or $('[type=file]', QR.el).files.length #not blank + return if QR.hasContent() e.preventDefault() QR.captchaPush @ quote: (e) -> @@ -1058,14 +1063,15 @@ QR = n = Math.ceil (cooldown - now) / 1000 b = $ 'button', QR.el if n > 0 - setTimeout QR.cooldown, 1000 $.extend b, textContent: n disabled: true + setTimeout QR.cooldown, 1000 else $.extend b, textContent: 'Submit' disabled: false + QR.autoPost() if $('#auto', QR.el).checked receive: (e) -> {data} = e if data @@ -1077,17 +1083,19 @@ QR = $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() submit: (e) -> + #XXX e is undefined if we're called from QR.autoPost $('.error', qr.el).textContent = '' if (el = $('#recaptcha_response_field', QR.el)).value QR.captchaPush el if not captcha = QR.captchaShift() alert 'You forgot to type in the verification.' - e.preventDefault() + e?.preventDefault() return {challenge, response} = captcha $('#challenge', QR.el).value = challenge $('#response', QR.el).value = response $('#autohide', QR.el).checked = true if conf['Auto Hide QR'] + $('#qr_form', QR.el).submit if not e sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild From 8b8778f3eed5a37975db27f4ba76a83a23c04cf1 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:19:19 -0700 Subject: [PATCH 022/130] QR.reset --- 4chan_x.user.js | 7 ++++++- script.coffee | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 61b434104..74e7ec264 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1367,13 +1367,18 @@ } } }, + reset: function() { + return $('textarea', QR.el).value = ''; + }, receive: function(e) { var data; data = e.data; if (data) { return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - if (!conf['Persistent QR']) { + if (conf['Persistent QR']) { + QR.reset(); + } else { QR.close(); } if (conf['Cooldown']) { diff --git a/script.coffee b/script.coffee index 7f948754e..e43142eb5 100644 --- a/script.coffee +++ b/script.coffee @@ -1072,12 +1072,17 @@ QR = textContent: 'Submit' disabled: false QR.autoPost() if $('#auto', QR.el).checked + reset: -> + $('textarea', QR.el).value = '' receive: (e) -> {data} = e if data $.extend $('a.error', QR.el), JSON.parse data else - QR.close() unless conf['Persistent QR'] + if conf['Persistent QR'] + QR.reset() + else + QR.close() if conf['Cooldown'] cooldown = Date.now() + 30*SECOND $.set "cooldown/#{g.BOARD}", cooldown From ad24caf3665afca553f304341988c8c63aa3e652 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:38:00 -0700 Subject: [PATCH 023/130] start attaching files --- 4chan_x.user.js | 18 +++++++++++++++++- script.coffee | 13 ++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 74e7ec264..a3e98b478 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1294,19 +1294,35 @@ QR.el = el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); if (conf['Cooldown']) { QR.cooldown; } $.bind($('.close', el), 'click', QR.close); $.bind($('form', el), 'submit', QR.submit); $.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown); + $.bind($('#attach', el), 'click', QR.attach); $.append(d.body, el); ta = $('textarea', el); l = text.length; ta.setSelectionRange(l, l); return ta.focus(); }, + change: function() { + $.unbind(this, 'change', QR.change); + return QR.attach(); + }, + attach: function() { + var div; + div = $.el('div', { + innerHTML: 'X' + }); + $.bind($('input', div), 'change', QR.change); + $.bind($('a', div), 'click', function() { + return $.rm(this.parentNode); + }); + return $.append($('#files', QR.el), div); + }, hasContent: function() { return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length; }, diff --git a/script.coffee b/script.coffee index e43142eb5..a4c76e673 100644 --- a/script.coffee +++ b/script.coffee @@ -1020,19 +1020,30 @@ QR =
#{$.get('captchas', []).length} captchas
-
+
+ " QR.cooldown if conf['Cooldown'] $.bind $('.close', el), 'click', QR.close $.bind $('form', el), 'submit', QR.submit $.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown + $.bind $('#attach', el), 'click', QR.attach $.append d.body, el ta = $ 'textarea', el l = text.length ta.setSelectionRange l, l ta.focus() + change: -> + $.unbind @, 'change', QR.change + QR.attach() + attach: -> + div = $.el 'div', + innerHTML: 'X' + $.bind $('input', div), 'change', QR.change + $.bind $('a', div), 'click', -> $.rm @parentNode + $.append $('#files', QR.el), div hasContent: -> $('textarea', QR.el).value or $('[type=file]', QR.el).files.length autoPost: -> From 32dfad4da1aa60b0c939423a1121db8af5643ddd Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:40:33 -0700 Subject: [PATCH 024/130] shuffle --- 4chan_x.user.js | 98 ++++++++++++++++++++++++------------------------- script.coffee | 60 +++++++++++++++--------------- 2 files changed, 79 insertions(+), 79 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a3e98b478..bf2e3b889 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1250,6 +1250,23 @@ } } }, + attach: function() { + var div; + div = $.el('div', { + innerHTML: 'X' + }); + $.bind($('input', div), 'change', QR.change); + $.bind($('a', div), 'click', function() { + return $.rm(this.parentNode); + }); + return $.append($('#files', QR.el), div); + }, + autoPost: function() { + if (!QR.hasContent()) { + return; + } + return QR.submit(); + }, captchaNode: function(e) { var c; c = e.target.value; @@ -1282,10 +1299,39 @@ $.set('captchas', captchas); return captcha; }, + change: function() { + $.unbind(this, 'change', QR.change); + return QR.attach(); + }, close: function() { $.rm(QR.el); return QR.el = null; }, + cooldown: function() { + var b, n, now; + if (!QR.el) { + return; + } + cooldown = $.get("cooldown/" + g.BOARD, 0); + now = Date.now(); + n = Math.ceil((cooldown - now) / 1000); + b = $('button', QR.el); + if (n > 0) { + $.extend(b, { + textContent: n, + disabled: true + }); + return setTimeout(QR.cooldown, 1000); + } else { + $.extend(b, { + textContent: 'Submit', + disabled: false + }); + if ($('#auto', QR.el).checked) { + return QR.autoPost(); + } + } + }, dialog: function(text) { var el, l, ta; if (text == null) { @@ -1308,30 +1354,9 @@ ta.setSelectionRange(l, l); return ta.focus(); }, - change: function() { - $.unbind(this, 'change', QR.change); - return QR.attach(); - }, - attach: function() { - var div; - div = $.el('div', { - innerHTML: 'X' - }); - $.bind($('input', div), 'change', QR.change); - $.bind($('a', div), 'click', function() { - return $.rm(this.parentNode); - }); - return $.append($('#files', QR.el), div); - }, hasContent: function() { return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length; }, - autoPost: function() { - if (!QR.hasContent()) { - return; - } - return QR.submit(); - }, keydown: function(e) { if (!(e.keyCode === 13 && this.value)) { return; @@ -1358,34 +1383,6 @@ ta.setSelectionRange(i, i); return ta.focus(); }, - cooldown: function() { - var b, n, now; - if (!QR.el) { - return; - } - cooldown = $.get("cooldown/" + g.BOARD, 0); - now = Date.now(); - n = Math.ceil((cooldown - now) / 1000); - b = $('button', QR.el); - if (n > 0) { - $.extend(b, { - textContent: n, - disabled: true - }); - return setTimeout(QR.cooldown, 1000); - } else { - $.extend(b, { - textContent: 'Submit', - disabled: false - }); - if ($('#auto', QR.el).checked) { - return QR.autoPost(); - } - } - }, - reset: function() { - return $('textarea', QR.el).value = ''; - }, receive: function(e) { var data; data = e.data; @@ -1404,6 +1401,9 @@ } } }, + reset: function() { + return $('textarea', QR.el).value = ''; + }, submit: function(e) { var captcha, challenge, el, response; $('.error', qr.el).textContent = ''; diff --git a/script.coffee b/script.coffee index a4c76e673..b147b296d 100644 --- a/script.coffee +++ b/script.coffee @@ -979,6 +979,15 @@ QR = qr.dialog() if conf['Auto Hide QR'] $('#autohide', QR.el).checked = true + attach: -> + div = $.el 'div', + innerHTML: 'X' + $.bind $('input', div), 'change', QR.change + $.bind $('a', div), 'click', -> $.rm @parentNode + $.append $('#files', QR.el), div + autoPost: -> + return unless QR.hasContent() + QR.submit() captchaNode: (e) -> c = e.target.value $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" @@ -1002,9 +1011,28 @@ QR = break $.set 'captchas', captchas captcha + change: -> + $.unbind @, 'change', QR.change + QR.attach() close: -> $.rm QR.el QR.el = null + cooldown: -> + return unless QR.el + cooldown = $.get "cooldown/#{g.BOARD}", 0 + now = Date.now() + n = Math.ceil (cooldown - now) / 1000 + b = $ 'button', QR.el + if n > 0 + $.extend b, + textContent: n + disabled: true + setTimeout QR.cooldown, 1000 + else + $.extend b, + textContent: 'Submit' + disabled: false + QR.autoPost() if $('#auto', QR.el).checked dialog: (text='') -> QR.el = el = ui.dialog 'qr', top: '0', left: '0', " X @@ -1035,20 +1063,8 @@ QR = l = text.length ta.setSelectionRange l, l ta.focus() - change: -> - $.unbind @, 'change', QR.change - QR.attach() - attach: -> - div = $.el 'div', - innerHTML: 'X' - $.bind $('input', div), 'change', QR.change - $.bind $('a', div), 'click', -> $.rm @parentNode - $.append $('#files', QR.el), div hasContent: -> $('textarea', QR.el).value or $('[type=file]', QR.el).files.length - autoPost: -> - return unless QR.hasContent() - QR.submit() keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled return if QR.hasContent() @@ -1067,24 +1083,6 @@ QR = i = ss + text.length ta.setSelectionRange i, i ta.focus() - cooldown: -> - return unless QR.el - cooldown = $.get "cooldown/#{g.BOARD}", 0 - now = Date.now() - n = Math.ceil (cooldown - now) / 1000 - b = $ 'button', QR.el - if n > 0 - $.extend b, - textContent: n - disabled: true - setTimeout QR.cooldown, 1000 - else - $.extend b, - textContent: 'Submit' - disabled: false - QR.autoPost() if $('#auto', QR.el).checked - reset: -> - $('textarea', QR.el).value = '' receive: (e) -> {data} = e if data @@ -1098,6 +1096,8 @@ QR = cooldown = Date.now() + 30*SECOND $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() + reset: -> + $('textarea', QR.el).value = '' submit: (e) -> #XXX e is undefined if we're called from QR.autoPost $('.error', qr.el).textContent = '' From 571ca1f9b90a0adb1fd826f7091f69b345fbd0bf Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 21:04:11 -0700 Subject: [PATCH 025/130] auto attach --- 4chan_x.user.js | 8 +++++--- script.coffee | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bf2e3b889..4941abc38 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1251,15 +1251,17 @@ } }, attach: function() { - var div; + var div, file; div = $.el('div', { innerHTML: 'X' }); - $.bind($('input', div), 'change', QR.change); + file = $('input', div); + $.bind(file, 'change', QR.change); $.bind($('a', div), 'click', function() { return $.rm(this.parentNode); }); - return $.append($('#files', QR.el), div); + $.append($('#files', QR.el), div); + return file.click(); }, autoPost: function() { if (!QR.hasContent()) { diff --git a/script.coffee b/script.coffee index b147b296d..140e730d3 100644 --- a/script.coffee +++ b/script.coffee @@ -982,9 +982,11 @@ QR = attach: -> div = $.el 'div', innerHTML: 'X' - $.bind $('input', div), 'change', QR.change + file = $ 'input', div + $.bind file, 'change', QR.change $.bind $('a', div), 'click', -> $.rm @parentNode $.append $('#files', QR.el), div + file.click() autoPost: -> return unless QR.hasContent() QR.submit() From 3a939f81eca0832ef078fe7adaf5b934e19c2654 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 22:11:01 -0700 Subject: [PATCH 026/130] autopost when attaching another file --- 4chan_x.user.js | 1 + script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index fc380fe52..5972d827b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1253,6 +1253,7 @@ }, attach: function() { var div, file; + $('#auto', QR.el).checked = true; div = $.el('div', { innerHTML: 'X' }); diff --git a/script.coffee b/script.coffee index 09921039f..ffc5d609f 100644 --- a/script.coffee +++ b/script.coffee @@ -980,6 +980,7 @@ QR = if conf['Auto Hide QR'] $('#autohide', QR.el).checked = true attach: -> + $('#auto', QR.el).checked = true div = $.el 'div', innerHTML: 'X' file = $ 'input', div From c35f959f4263f24c81872a954ea83013c6110135 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 22:20:23 -0700 Subject: [PATCH 027/130] reset file --- 4chan_x.user.js | 17 ++++++++++++----- script.coffee | 11 ++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5972d827b..77dba3b61 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1388,13 +1388,13 @@ return ta.focus(); }, receive: function(e) { - var data; + var data, file; data = e.data; if (data) { return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - if (conf['Persistent QR']) { - QR.reset(); + if (((file = $('#files input', QR.el)) && file.files.length) || conf['Persistent QR']) { + QR.reset(file); } else { QR.close(); } @@ -1405,8 +1405,15 @@ } } }, - reset: function() { - return $('textarea', QR.el).value = ''; + reset: function(file) { + var oldFile; + $('textarea', QR.el).value = ''; + oldFile = $('[type=file]', QR.el); + file || (file = $.el('input', { + type: 'file', + name: 'upfile' + })); + return $.replace(oldFile, file); }, submit: function(e) { var captcha, challenge, el, response; diff --git a/script.coffee b/script.coffee index ffc5d609f..368556617 100644 --- a/script.coffee +++ b/script.coffee @@ -1091,16 +1091,21 @@ QR = if data $.extend $('a.error', QR.el), JSON.parse data else - if conf['Persistent QR'] - QR.reset() + if ((file = $('#files input', QR.el)) and file.files.length) or conf['Persistent QR'] + QR.reset file else QR.close() if conf['Cooldown'] cooldown = Date.now() + 30*SECOND $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() - reset: -> + reset: (file) -> $('textarea', QR.el).value = '' + oldFile = $ '[type=file]', QR.el + file or= $.el 'input', + type: 'file' + name: 'upfile' + $.replace oldFile, file submit: (e) -> #XXX e is undefined if we're called from QR.autoPost $('.error', qr.el).textContent = '' From a43711ba27ff347fa833194de674c293a7640294 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 22:45:19 -0700 Subject: [PATCH 028/130] fix for auto posting --- 4chan_x.user.js | 7 +++---- script.coffee | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 77dba3b61..6a274d381 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1365,11 +1365,10 @@ if (!(e.keyCode === 13 && this.value)) { return; } - if (QR.hasContent()) { - return; + QR.captchaPush(this); + if (!QR.hasContent()) { + return e.preventDefault(); } - e.preventDefault(); - return QR.captchaPush(this); }, quote: function(e) { var i, ss, ta, text, v; diff --git a/script.coffee b/script.coffee index 368556617..a1008a4e9 100644 --- a/script.coffee +++ b/script.coffee @@ -1070,9 +1070,8 @@ QR = $('textarea', QR.el).value or $('[type=file]', QR.el).files.length keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled - return if QR.hasContent() - e.preventDefault() QR.captchaPush @ + e.preventDefault() unless QR.hasContent() quote: (e) -> e.preventDefault() text = ">>#{@textContent}\n" From 41af79fcd6aff5461823189346c390970079d84e Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 22:50:47 -0700 Subject: [PATCH 029/130] derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6a274d381..898218adb 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1245,7 +1245,7 @@ target: holder.firstChild }); if (conf['Persistent QR']) { - qr.dialog(); + QR.dialog(); if (conf['Auto Hide QR']) { return $('#autohide', QR.el).checked = true; } diff --git a/script.coffee b/script.coffee index a1008a4e9..2d1cebd78 100644 --- a/script.coffee +++ b/script.coffee @@ -976,7 +976,7 @@ QR = $.bind holder, 'DOMNodeInserted', QR.captchaNode QR.captchaNode target: holder.firstChild if conf['Persistent QR'] - qr.dialog() + QR.dialog() if conf['Auto Hide QR'] $('#autohide', QR.el).checked = true attach: -> From a0ac470623f8debb3640ffb6c5f8cf22bb6a81a0 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 22:56:53 -0700 Subject: [PATCH 030/130] derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 898218adb..a1cbbaf1b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1434,7 +1434,7 @@ $('#autohide', QR.el).checked = true; } if (!e) { - return $('#qr_form', QR.el).submit; + return $('#qr_form', QR.el).submit(); } }, sys: function() { diff --git a/script.coffee b/script.coffee index 2d1cebd78..078cf5bb3 100644 --- a/script.coffee +++ b/script.coffee @@ -1118,7 +1118,7 @@ QR = $('#challenge', QR.el).value = challenge $('#response', QR.el).value = response $('#autohide', QR.el).checked = true if conf['Auto Hide QR'] - $('#qr_form', QR.el).submit if not e + $('#qr_form', QR.el).submit() if not e sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild From 4f6c79a3710ec643f7744a7be3286c118ed8cb8a Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:00:20 -0700 Subject: [PATCH 031/130] handle dup files --- 4chan_x.user.js | 45 ++++++++++++++++++++++++++------------------- script.coffee | 31 ++++++++++++++++++------------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a1cbbaf1b..03e69e634 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1265,6 +1265,15 @@ $.append($('#files', QR.el), div); return file.click(); }, + attachNext: function(file) { + var oldFile; + oldFile = $('[type=file]', QR.el); + file || (file = $.el('input', { + type: 'file', + name: 'upfile' + })); + return $.replace(oldFile, file); + }, autoPost: function() { if (!QR.hasContent()) { return; @@ -1387,32 +1396,30 @@ return ta.focus(); }, receive: function(e) { - var data, file; + var data, file, tc; data = e.data; if (data) { - return $.extend($('a.error', QR.el), JSON.parse(data)); + $.extend($('a.error', QR.el), JSON.parse(data)); + tc = data.textContent; + if (tc === 'Error: Duplicate file entry detected.') { + QR.attachNext(); + } + return; + } + if (((file = $('#files input', QR.el)) && file.files.length) || conf['Persistent QR']) { + QR.reset(file); } else { - if (((file = $('#files input', QR.el)) && file.files.length) || conf['Persistent QR']) { - QR.reset(file); - } else { - QR.close(); - } - if (conf['Cooldown']) { - cooldown = Date.now() + 30 * SECOND; - $.set("cooldown/" + g.BOARD, cooldown); - return QR.cooldown(); - } + QR.close(); + } + if (conf['Cooldown']) { + cooldown = Date.now() + 30 * SECOND; + $.set("cooldown/" + g.BOARD, cooldown); + return QR.cooldown(); } }, reset: function(file) { - var oldFile; $('textarea', QR.el).value = ''; - oldFile = $('[type=file]', QR.el); - file || (file = $.el('input', { - type: 'file', - name: 'upfile' - })); - return $.replace(oldFile, file); + return QR.attachNext(file); }, submit: function(e) { var captcha, challenge, el, response; diff --git a/script.coffee b/script.coffee index 078cf5bb3..cdb84f3fd 100644 --- a/script.coffee +++ b/script.coffee @@ -988,6 +988,12 @@ QR = $.bind $('a', div), 'click', -> $.rm @parentNode $.append $('#files', QR.el), div file.click() + attachNext: (file) -> + oldFile = $ '[type=file]', QR.el + file or= $.el 'input', + type: 'file' + name: 'upfile' + $.replace oldFile, file autoPost: -> return unless QR.hasContent() QR.submit() @@ -1089,22 +1095,21 @@ QR = {data} = e if data $.extend $('a.error', QR.el), JSON.parse data + tc = data.textContent + if tc is 'Error: Duplicate file entry detected.' + QR.attachNext() + return + if ((file = $('#files input', QR.el)) and file.files.length) or conf['Persistent QR'] + QR.reset file else - if ((file = $('#files input', QR.el)) and file.files.length) or conf['Persistent QR'] - QR.reset file - else - QR.close() - if conf['Cooldown'] - cooldown = Date.now() + 30*SECOND - $.set "cooldown/#{g.BOARD}", cooldown - QR.cooldown() + QR.close() + if conf['Cooldown'] + cooldown = Date.now() + 30*SECOND + $.set "cooldown/#{g.BOARD}", cooldown + QR.cooldown() reset: (file) -> $('textarea', QR.el).value = '' - oldFile = $ '[type=file]', QR.el - file or= $.el 'input', - type: 'file' - name: 'upfile' - $.replace oldFile, file + QR.attachNext file submit: (e) -> #XXX e is undefined if we're called from QR.autoPost $('.error', qr.el).textContent = '' From 796e3836548134d0d5f6f1fe8f93ba37bed73b1e Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:07:30 -0700 Subject: [PATCH 032/130] better attachNext & co --- 4chan_x.user.js | 26 +++++++++++++++----------- script.coffee | 19 +++++++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 03e69e634..3a0a57c7b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1265,13 +1265,17 @@ $.append($('#files', QR.el), div); return file.click(); }, - attachNext: function(file) { - var oldFile; + attachNext: function() { + var file, oldFile; oldFile = $('[type=file]', QR.el); - file || (file = $.el('input', { - type: 'file', - name: 'upfile' - })); + if (file = $('#files input', QR.el)) { + $.rm(file.parentNode); + } else { + file = $.el('input', { + type: 'file', + name: 'upfile' + }); + } return $.replace(oldFile, file); }, autoPost: function() { @@ -1396,7 +1400,7 @@ return ta.focus(); }, receive: function(e) { - var data, file, tc; + var data, tc, _ref; data = e.data; if (data) { $.extend($('a.error', QR.el), JSON.parse(data)); @@ -1406,8 +1410,8 @@ } return; } - if (((file = $('#files input', QR.el)) && file.files.length) || conf['Persistent QR']) { - QR.reset(file); + if (conf['Persistent QR'] || ((_ref = $('#files input', QR.el)) != null ? _ref.files.length : void 0)) { + QR.reset(); } else { QR.close(); } @@ -1417,9 +1421,9 @@ return QR.cooldown(); } }, - reset: function(file) { + reset: function() { $('textarea', QR.el).value = ''; - return QR.attachNext(file); + return QR.attachNext(); }, submit: function(e) { var captcha, challenge, el, response; diff --git a/script.coffee b/script.coffee index cdb84f3fd..0fce5e2bc 100644 --- a/script.coffee +++ b/script.coffee @@ -988,11 +988,14 @@ QR = $.bind $('a', div), 'click', -> $.rm @parentNode $.append $('#files', QR.el), div file.click() - attachNext: (file) -> + attachNext: -> oldFile = $ '[type=file]', QR.el - file or= $.el 'input', - type: 'file' - name: 'upfile' + if file = $ '#files input', QR.el + $.rm file.parentNode + else + file = $.el 'input', + type: 'file' + name: 'upfile' $.replace oldFile, file autoPost: -> return unless QR.hasContent() @@ -1099,17 +1102,17 @@ QR = if tc is 'Error: Duplicate file entry detected.' QR.attachNext() return - if ((file = $('#files input', QR.el)) and file.files.length) or conf['Persistent QR'] - QR.reset file + if conf['Persistent QR'] or $('#files input', QR.el)?.files.length + QR.reset() else QR.close() if conf['Cooldown'] cooldown = Date.now() + 30*SECOND $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() - reset: (file) -> + reset: -> $('textarea', QR.el).value = '' - QR.attachNext file + QR.attachNext() submit: (e) -> #XXX e is undefined if we're called from QR.autoPost $('.error', qr.el).textContent = '' From 5ef564f5986497009e5a27da4ee8cdec794f9336 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:12:45 -0700 Subject: [PATCH 033/130] *really* handle dups --- 4chan_x.user.js | 1 + script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3a0a57c7b..58c506d9d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1407,6 +1407,7 @@ tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { QR.attachNext(); + QR.submit(); } return; } diff --git a/script.coffee b/script.coffee index 0fce5e2bc..9ca9ecd38 100644 --- a/script.coffee +++ b/script.coffee @@ -1101,6 +1101,7 @@ QR = tc = data.textContent if tc is 'Error: Duplicate file entry detected.' QR.attachNext() + QR.submit() return if conf['Persistent QR'] or $('#files input', QR.el)?.files.length QR.reset() From 32ea0a2cb573b00137406748da176022ccdb0f91 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:14:01 -0700 Subject: [PATCH 034/130] display correct captcha length --- 4chan_x.user.js | 1 + script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 58c506d9d..c38f565da 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1314,6 +1314,7 @@ } } $.set('captchas', captchas); + $('#cl', QR.el).textContent = captchas.length; return captcha; }, change: function() { diff --git a/script.coffee b/script.coffee index 9ca9ecd38..a96aec0e4 100644 --- a/script.coffee +++ b/script.coffee @@ -1022,6 +1022,7 @@ QR = if captcha.time > cutoff break $.set 'captchas', captchas + $('#cl', QR.el).textContent = captchas.length captcha change: -> $.unbind @, 'change', QR.change From e7c77f7cb5f380d3a0a4c72e1d4cae1525cfde1d Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:18:26 -0700 Subject: [PATCH 035/130] parse data, handle mistyped captcha --- 4chan_x.user.js | 5 ++++- script.coffee | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c38f565da..8746a9d68 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1404,11 +1404,14 @@ var data, tc, _ref; data = e.data; if (data) { - $.extend($('a.error', QR.el), JSON.parse(data)); + data = JSON.parse(data); + $.extend($('a.error', QR.el), data); tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { QR.attachNext(); QR.submit(); + } else if (tc === 'You seem to have mistyped the verification.') { + QR.submit(); } return; } diff --git a/script.coffee b/script.coffee index a96aec0e4..f77feb253 100644 --- a/script.coffee +++ b/script.coffee @@ -1098,11 +1098,14 @@ QR = receive: (e) -> {data} = e if data - $.extend $('a.error', QR.el), JSON.parse data + data = JSON.parse data + $.extend $('a.error', QR.el), data tc = data.textContent if tc is 'Error: Duplicate file entry detected.' QR.attachNext() QR.submit() + else if tc is 'You seem to have mistyped the verification.' + QR.submit() return if conf['Persistent QR'] or $('#files input', QR.el)?.files.length QR.reset() From de27220c0d11b8ec7a8e707096e8d428ba2c5d73 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:21:12 -0700 Subject: [PATCH 036/130] 1s delay --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8746a9d68..81b42fc7a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1409,9 +1409,9 @@ tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { QR.attachNext(); - QR.submit(); + setTimeout(QR.submit, 1000); } else if (tc === 'You seem to have mistyped the verification.') { - QR.submit(); + setTimeout(QR.submit, 1000); } return; } diff --git a/script.coffee b/script.coffee index f77feb253..59e3de7af 100644 --- a/script.coffee +++ b/script.coffee @@ -1103,9 +1103,9 @@ QR = tc = data.textContent if tc is 'Error: Duplicate file entry detected.' QR.attachNext() - QR.submit() + setTimeout QR.submit, 1000 else if tc is 'You seem to have mistyped the verification.' - QR.submit() + setTimeout QR.submit, 1000 return if conf['Persistent QR'] or $('#files input', QR.el)?.files.length QR.reset() From ebcfc8e7b0d047ea9e54c8f51042e340c1db4154 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:42:19 -0700 Subject: [PATCH 037/130] accept --- 4chan_x.user.js | 20 ++++++++++++++++---- script.coffee | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 81b42fc7a..78b7e2441 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1227,7 +1227,7 @@ }; QR = { init: function() { - var holder; + var accept, holder; g.callbacks.push(function(root) { var quote; quote = $('a.quotejs + a', root); @@ -1244,6 +1244,17 @@ QR.captchaNode({ target: holder.firstChild }); + accept = $('.rules').textContent.match(/: (.+) /)[1].replace(/\w+/g, function(type) { + switch (type) { + case 'JPG': + return 'image/JPEG'; + case 'PDF': + return 'application/' + type; + default: + return 'image/' + type; + } + }); + QR.accept = "'" + accept + "'"; if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { @@ -1255,7 +1266,7 @@ var div, file; $('#auto', QR.el).checked = true; div = $.el('div', { - innerHTML: 'X' + innerHTML: "X" }); file = $('input', div); $.bind(file, 'change', QR.change); @@ -1273,7 +1284,8 @@ } else { file = $.el('input', { type: 'file', - name: 'upfile' + name: 'upfile', + accept: QR.accept }); } return $.replace(oldFile, file); @@ -1358,7 +1370,7 @@ QR.el = el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); if (conf['Cooldown']) { QR.cooldown; } diff --git a/script.coffee b/script.coffee index 59e3de7af..cf942d472 100644 --- a/script.coffee +++ b/script.coffee @@ -975,6 +975,15 @@ QR = holder = $ '#recaptcha_challenge_field_holder' $.bind holder, 'DOMNodeInserted', QR.captchaNode QR.captchaNode target: holder.firstChild + accept = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) -> + switch type + when 'JPG' + 'image/JPEG' + when 'PDF' + 'application/' + type + else + 'image/' + type + QR.accept = "'#{accept}'" if conf['Persistent QR'] QR.dialog() if conf['Auto Hide QR'] @@ -982,7 +991,7 @@ QR = attach: -> $('#auto', QR.el).checked = true div = $.el 'div', - innerHTML: 'X' + innerHTML: "X" file = $ 'input', div $.bind file, 'change', QR.change $.bind $('a', div), 'click', -> $.rm @parentNode @@ -996,6 +1005,7 @@ QR = file = $.el 'input', type: 'file' name: 'upfile' + accept: QR.accept $.replace oldFile, file autoPost: -> return unless QR.hasContent() @@ -1060,7 +1070,7 @@ QR =
#{$.get('captchas', []).length} captchas
-
+
From d751784a143e8db264c9f73c0f11d2be348ba31c Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 23:46:13 -0700 Subject: [PATCH 038/130] spoiler --- 4chan_x.user.js | 9 ++++++++- script.coffee | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 78b7e2441..c950b999e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1255,6 +1255,7 @@ } }); QR.accept = "'" + accept + "'"; + QR.spoiler = $('.postarea label') ? ' ' : ''; if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { @@ -1370,7 +1371,7 @@ QR.el = el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); if (conf['Cooldown']) { QR.cooldown; } @@ -1439,6 +1440,12 @@ } }, reset: function() { + var _ref; + if (!conf['Remember Spoiler']) { + if ((_ref = $('[name=spoiler]', QR.el)) != null) { + _ref.checked = false; + } + } $('textarea', QR.el).value = ''; return QR.attachNext(); }, diff --git a/script.coffee b/script.coffee index cf942d472..c58400099 100644 --- a/script.coffee +++ b/script.coffee @@ -984,6 +984,7 @@ QR = else 'image/' + type QR.accept = "'#{accept}'" + QR.spoiler = if $('.postarea label') then ' ' else '' if conf['Persistent QR'] QR.dialog() if conf['Auto Hide QR'] @@ -1065,7 +1066,7 @@ QR = -
+
#{QR.spoiler}
@@ -1126,6 +1127,7 @@ QR = $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() reset: -> + $('[name=spoiler]', QR.el)?.checked = false unless conf['Remember Spoiler'] $('textarea', QR.el).value = '' QR.attachNext() submit: (e) -> From b4c43a10bb881111bd10d0e57ef40b9ea03c636f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 00:29:14 -0700 Subject: [PATCH 039/130] QR.el -> QR.qr --- 4chan_x.user.js | 69 +++++++++++++++++++++++++------------------------ script.coffee | 65 +++++++++++++++++++++++----------------------- 2 files changed, 68 insertions(+), 66 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c950b999e..200be0d0f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1259,13 +1259,13 @@ if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { - return $('#autohide', QR.el).checked = true; + return $('#autohide', QR.qr).checked = true; } } }, attach: function() { var div, file; - $('#auto', QR.el).checked = true; + $('#auto', QR.qr).checked = true; div = $.el('div', { innerHTML: "X" }); @@ -1274,13 +1274,13 @@ $.bind($('a', div), 'click', function() { return $.rm(this.parentNode); }); - $.append($('#files', QR.el), div); + $.append($('#files', QR.qr), div); return file.click(); }, attachNext: function() { var file, oldFile; - oldFile = $('[type=file]', QR.el); - if (file = $('#files input', QR.el)) { + oldFile = $('[type=file]', QR.qr); + if (file = $('#files input', QR.qr)) { $.rm(file.parentNode); } else { file = $.el('input', { @@ -1300,7 +1300,7 @@ captchaNode: function(e) { var c; c = e.target.value; - $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=" + c; + $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; return QR.captcha = { challenge: c, time: Date.now() @@ -1327,7 +1327,7 @@ } } $.set('captchas', captchas); - $('#cl', QR.el).textContent = captchas.length; + $('#cl', QR.qr).textContent = captchas.length; return captcha; }, change: function() { @@ -1335,18 +1335,18 @@ return QR.attach(); }, close: function() { - $.rm(QR.el); - return QR.el = null; + $.rm(QR.qr); + return QR.qr = null; }, cooldown: function() { var b, n, now; - if (!QR.el) { + if (!QR.qr) { return; } cooldown = $.get("cooldown/" + g.BOARD, 0); now = Date.now(); n = Math.ceil((cooldown - now) / 1000); - b = $('button', QR.el); + b = $('button', QR.qr); if (n > 0) { $.extend(b, { textContent: n, @@ -1358,35 +1358,35 @@ textContent: 'Submit', disabled: false }); - if ($('#auto', QR.el).checked) { + if ($('#auto', QR.qr).checked) { return QR.autoPost(); } } }, dialog: function(text) { - var el, l, ta; + var l, qr, ta; if (text == null) { text = ''; } - QR.el = el = ui.dialog('qr', { + QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); if (conf['Cooldown']) { QR.cooldown; } - $.bind($('.close', el), 'click', QR.close); - $.bind($('form', el), 'submit', QR.submit); - $.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown); - $.bind($('#attach', el), 'click', QR.attach); - $.append(d.body, el); - ta = $('textarea', el); + $.bind($('.close', qr), 'click', QR.close); + $.bind($('form', qr), 'submit', QR.submit); + $.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown); + $.bind($('#attach', qr), 'click', QR.attach); + $.append(d.body, qr); + ta = $('textarea', qr); l = text.length; ta.setSelectionRange(l, l); return ta.focus(); }, hasContent: function() { - return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length; + return $('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length; }, keydown: function(e) { if (!(e.keyCode === 13 && this.value)) { @@ -1401,11 +1401,11 @@ var i, ss, ta, text, v; e.preventDefault(); text = ">>" + this.textContent + "\n"; - if (!QR.el) { + if (!QR.qr) { QR.dialog(text); return; } - ta = $('textarea', QR.el); + ta = $('textarea', QR.qr); v = ta.value; ss = ta.selectionStart; ta.value = v.slice(0, ss) + text + v.slice(ss); @@ -1418,7 +1418,7 @@ data = e.data; if (data) { data = JSON.parse(data); - $.extend($('a.error', QR.el), data); + $.extend($('a.error', QR.qr), data); tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { QR.attachNext(); @@ -1428,7 +1428,7 @@ } return; } - if (conf['Persistent QR'] || ((_ref = $('#files input', QR.el)) != null ? _ref.files.length : void 0)) { + if (conf['Persistent QR'] || ((_ref = $('#files input', QR.qr)) != null ? _ref.files.length : void 0)) { QR.reset(); } else { QR.close(); @@ -1442,17 +1442,18 @@ reset: function() { var _ref; if (!conf['Remember Spoiler']) { - if ((_ref = $('[name=spoiler]', QR.el)) != null) { + if ((_ref = $('[name=spoiler]', QR.qr)) != null) { _ref.checked = false; } } - $('textarea', QR.el).value = ''; + $('textarea', QR.qr).value = ''; return QR.attachNext(); }, submit: function(e) { - var captcha, challenge, el, response; - $('.error', qr.el).textContent = ''; - if ((el = $('#recaptcha_response_field', QR.el)).value) { + var captcha, challenge, el, qr, response; + qr = QR.qr; + $('.error', qr).textContent = ''; + if ((el = $('#recaptcha_response_field', qr)).value) { QR.captchaPush(el); } if (!(captcha = QR.captchaShift())) { @@ -1463,13 +1464,13 @@ return; } challenge = captcha.challenge, response = captcha.response; - $('#challenge', QR.el).value = challenge; - $('#response', QR.el).value = response; + $('#challenge', qr).value = challenge; + $('#response', qr).value = response; if (conf['Auto Hide QR']) { - $('#autohide', QR.el).checked = true; + $('#autohide', qr).checked = true; } if (!e) { - return $('#qr_form', QR.el).submit(); + return $('#qr_form', qr).submit(); } }, sys: function() { diff --git a/script.coffee b/script.coffee index c58400099..4d2742b42 100644 --- a/script.coffee +++ b/script.coffee @@ -988,19 +988,19 @@ QR = if conf['Persistent QR'] QR.dialog() if conf['Auto Hide QR'] - $('#autohide', QR.el).checked = true + $('#autohide', QR.qr).checked = true attach: -> - $('#auto', QR.el).checked = true + $('#auto', QR.qr).checked = true div = $.el 'div', innerHTML: "X" file = $ 'input', div $.bind file, 'change', QR.change $.bind $('a', div), 'click', -> $.rm @parentNode - $.append $('#files', QR.el), div + $.append $('#files', QR.qr), div file.click() attachNext: -> - oldFile = $ '[type=file]', QR.el - if file = $ '#files input', QR.el + oldFile = $ '[type=file]', QR.qr + if file = $ '#files input', QR.qr $.rm file.parentNode else file = $.el 'input', @@ -1013,7 +1013,7 @@ QR = QR.submit() captchaNode: (e) -> c = e.target.value - $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" + $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" QR.captcha = challenge: c time: Date.now() @@ -1033,20 +1033,20 @@ QR = if captcha.time > cutoff break $.set 'captchas', captchas - $('#cl', QR.el).textContent = captchas.length + $('#cl', QR.qr).textContent = captchas.length captcha change: -> $.unbind @, 'change', QR.change QR.attach() close: -> - $.rm QR.el - QR.el = null + $.rm QR.qr + QR.qr = null cooldown: -> - return unless QR.el + return unless QR.qr cooldown = $.get "cooldown/#{g.BOARD}", 0 now = Date.now() n = Math.ceil (cooldown - now) / 1000 - b = $ 'button', QR.el + b = $ 'button', QR.qr if n > 0 $.extend b, textContent: n @@ -1056,9 +1056,9 @@ QR = $.extend b, textContent: 'Submit' disabled: false - QR.autoPost() if $('#auto', QR.el).checked + QR.autoPost() if $('#auto', QR.qr).checked dialog: (text='') -> - QR.el = el = ui.dialog 'qr', top: '0', left: '0', " + QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " X
Quick Reply
@@ -1078,17 +1078,17 @@ QR = " QR.cooldown if conf['Cooldown'] - $.bind $('.close', el), 'click', QR.close - $.bind $('form', el), 'submit', QR.submit - $.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown - $.bind $('#attach', el), 'click', QR.attach - $.append d.body, el - ta = $ 'textarea', el + $.bind $('.close', qr), 'click', QR.close + $.bind $('form', qr), 'submit', QR.submit + $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown + $.bind $('#attach', qr), 'click', QR.attach + $.append d.body, qr + ta = $ 'textarea', qr l = text.length ta.setSelectionRange l, l ta.focus() hasContent: -> - $('textarea', QR.el).value or $('[type=file]', QR.el).files.length + $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled QR.captchaPush @ @@ -1096,10 +1096,10 @@ QR = quote: (e) -> e.preventDefault() text = ">>#{@textContent}\n" - if not QR.el + if not QR.qr QR.dialog text return - ta = $ 'textarea', QR.el + ta = $ 'textarea', QR.qr v = ta.value ss = ta.selectionStart ta.value = v[0...ss] + text + v[ss..] @@ -1110,7 +1110,7 @@ QR = {data} = e if data data = JSON.parse data - $.extend $('a.error', QR.el), data + $.extend $('a.error', QR.qr), data tc = data.textContent if tc is 'Error: Duplicate file entry detected.' QR.attachNext() @@ -1118,7 +1118,7 @@ QR = else if tc is 'You seem to have mistyped the verification.' setTimeout QR.submit, 1000 return - if conf['Persistent QR'] or $('#files input', QR.el)?.files.length + if conf['Persistent QR'] or $('#files input', QR.qr)?.files.length QR.reset() else QR.close() @@ -1127,23 +1127,24 @@ QR = $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() reset: -> - $('[name=spoiler]', QR.el)?.checked = false unless conf['Remember Spoiler'] - $('textarea', QR.el).value = '' + $('[name=spoiler]', QR.qr)?.checked = false unless conf['Remember Spoiler'] + $('textarea', QR.qr).value = '' QR.attachNext() submit: (e) -> #XXX e is undefined if we're called from QR.autoPost - $('.error', qr.el).textContent = '' - if (el = $('#recaptcha_response_field', QR.el)).value + {qr} = QR + $('.error', qr).textContent = '' + if (el = $('#recaptcha_response_field', qr)).value QR.captchaPush el if not captcha = QR.captchaShift() alert 'You forgot to type in the verification.' e?.preventDefault() return {challenge, response} = captcha - $('#challenge', QR.el).value = challenge - $('#response', QR.el).value = response - $('#autohide', QR.el).checked = true if conf['Auto Hide QR'] - $('#qr_form', QR.el).submit() if not e + $('#challenge', qr).value = challenge + $('#response', qr).value = response + $('#autohide', qr).checked = true if conf['Auto Hide QR'] + $('#qr_form', qr).submit() if not e sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild From dd1c202696e5619752ddbbbd20390e50da72d33a Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 00:32:56 -0700 Subject: [PATCH 040/130] sage cooldown --- 4chan_x.user.js | 5 +++-- script.coffee | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 200be0d0f..fc9dfb106 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1434,7 +1434,7 @@ QR.close(); } if (conf['Cooldown']) { - cooldown = Date.now() + 30 * SECOND; + cooldown = Date.now() + (QR.sage ? 60 : 30) * SECOND; $.set("cooldown/" + g.BOARD, cooldown); return QR.cooldown(); } @@ -1470,8 +1470,9 @@ $('#autohide', qr).checked = true; } if (!e) { - return $('#qr_form', qr).submit(); + $('#qr_form', qr).submit(); } + return QR.sage = /sage/i.test($('[name=email]', qr).value); }, sys: function() { return $.globalEval(function() { diff --git a/script.coffee b/script.coffee index 4d2742b42..954ff2498 100644 --- a/script.coffee +++ b/script.coffee @@ -1123,7 +1123,7 @@ QR = else QR.close() if conf['Cooldown'] - cooldown = Date.now() + 30*SECOND + cooldown = Date.now() + (if QR.sage then 60 else 30)*SECOND $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() reset: -> @@ -1145,6 +1145,7 @@ QR = $('#response', qr).value = response $('#autohide', qr).checked = true if conf['Auto Hide QR'] $('#qr_form', qr).submit() if not e + QR.sage = /sage/i.test $('[name=email]', qr).value sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild From 814e6969895e171108b593c26853ac9186580109 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 11:13:34 -0700 Subject: [PATCH 041/130] fix cl --- 4chan_x.user.js | 2 +- script.coffee | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a9696438b..c133f236c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1327,7 +1327,7 @@ } } $.set('captchas', captchas); - $('#cl', QR.qr).textContent = captchas.length; + $('#cl', QR.qr).textContent = captchas.length + ' captchas'; return captcha; }, change: function() { diff --git a/script.coffee b/script.coffee index 55e5a6a4d..d175babc1 100644 --- a/script.coffee +++ b/script.coffee @@ -961,6 +961,7 @@ cooldown = qr.autoPost() QR = + #FIXME duplication everywhere init: -> g.callbacks.push (root) -> quote = $ 'a.quotejs + a', root @@ -1032,7 +1033,7 @@ QR = if captcha.time > cutoff break $.set 'captchas', captchas - $('#cl', QR.qr).textContent = captchas.length + $('#cl', QR.qr).textContent = captchas.length + ' captchas' captcha change: -> $.unbind @, 'change', QR.change From f81d0a575dcd049fa287863e0dd67aaf2fc750cf Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:14:59 -0700 Subject: [PATCH 042/130] cookie --- 4chan_x.user.js | 6 +++++- script.coffee | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c133f236c..451c587d4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1364,7 +1364,7 @@ } }, dialog: function(text) { - var l, qr, ta; + var c, l, m, qr, ta; if (text == null) { text = ''; } @@ -1372,6 +1372,10 @@ top: '0', left: '0' }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); + c = d.cookie; + $('[name=name]', el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=email]', el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=pwd]', el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; if (conf['Cooldown']) { QR.cooldown; } diff --git a/script.coffee b/script.coffee index d175babc1..e941d52b7 100644 --- a/script.coffee +++ b/script.coffee @@ -1077,6 +1077,11 @@ QR = " + #XXX use dom methods to set values instead of injecting raw user input into your html -_-; + c = d.cookie + $('[name=name]', el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=email]', el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=pwd]', el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value QR.cooldown if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit From 9f21c5df3548b2a724421155576205e16bb3e712 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:33:46 -0700 Subject: [PATCH 043/130] comment --- script.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.coffee b/script.coffee index e941d52b7..14987e149 100644 --- a/script.coffee +++ b/script.coffee @@ -961,7 +961,7 @@ cooldown = qr.autoPost() QR = - #FIXME duplication everywhere + #FIXME DRY init: -> g.callbacks.push (root) -> quote = $ 'a.quotejs + a', root From 6d80885a5dff9f86724b792485204b587901f3f3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:43:27 -0700 Subject: [PATCH 044/130] merge QR.autoPost into QR.submit --- 4chan_x.user.js | 14 +++++++------- script.coffee | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 451c587d4..b9f667587 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1291,12 +1291,6 @@ } return $.replace(oldFile, file); }, - autoPost: function() { - if (!QR.hasContent()) { - return; - } - return QR.submit(); - }, captchaNode: function(e) { var c; c = e.target.value; @@ -1359,7 +1353,7 @@ disabled: false }); if ($('#auto', QR.qr).checked) { - return QR.autoPost(); + return QR.submit(); } } }, @@ -1455,6 +1449,12 @@ }, submit: function(e) { var captcha, challenge, el, qr, response; + if (!QR.hasContent()) { + if (e) { + alert('Error: No text entered.'); + } + return; + } qr = QR.qr; $('.error', qr).textContent = ''; if ((el = $('#recaptcha_response_field', qr)).value) { diff --git a/script.coffee b/script.coffee index 14987e149..cccc4f6dd 100644 --- a/script.coffee +++ b/script.coffee @@ -1008,9 +1008,6 @@ QR = name: 'upfile' accept: QR.accept $.replace oldFile, file - autoPost: -> - return unless QR.hasContent() - QR.submit() captchaNode: (e) -> c = e.target.value $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" @@ -1056,7 +1053,7 @@ QR = $.extend b, textContent: 'Submit' disabled: false - QR.autoPost() if $('#auto', QR.qr).checked + QR.submit() if $('#auto', QR.qr).checked dialog: (text='') -> QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " X @@ -1136,7 +1133,10 @@ QR = $('textarea', QR.qr).value = '' QR.attachNext() submit: (e) -> - #XXX e is undefined if we're called from QR.autoPost + #XXX e is undefined if method is called explicitly, eg, from auto posting + unless QR.hasContent() + alert 'Error: No text entered.' if e + return {qr} = QR $('.error', qr).textContent = '' if (el = $('#recaptcha_response_field', qr)).value From 5ffcb63fb3faae95972f2f4339cb9e9899eb395d Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:46:17 -0700 Subject: [PATCH 045/130] comment --- script.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.coffee b/script.coffee index cccc4f6dd..d8cb7605e 100644 --- a/script.coffee +++ b/script.coffee @@ -1135,7 +1135,7 @@ QR = submit: (e) -> #XXX e is undefined if method is called explicitly, eg, from auto posting unless QR.hasContent() - alert 'Error: No text entered.' if e + alert 'Error: No text entered.' if e #don't alert at the end of auto posting return {qr} = QR $('.error', qr).textContent = '' From 56aa4f92f12924749666fe6b036a1eea2703b065 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:48:46 -0700 Subject: [PATCH 046/130] derpy, prevent calling QR.hasContent twice --- 4chan_x.user.js | 5 ++--- script.coffee | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b9f667587..11209e783 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1391,9 +1391,8 @@ return; } QR.captchaPush(this); - if (!QR.hasContent()) { - return e.preventDefault(); - } + e.preventDefault(); + return e.submit(); }, quote: function(e) { var i, ss, ta, text, v; diff --git a/script.coffee b/script.coffee index d8cb7605e..ab379d067 100644 --- a/script.coffee +++ b/script.coffee @@ -1094,7 +1094,8 @@ QR = keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled QR.captchaPush @ - e.preventDefault() unless QR.hasContent() + e.preventDefault() + e.submit() #derpy, but prevents calling QR.hasContent twice quote: (e) -> e.preventDefault() text = ">>#{@textContent}\n" From f8739831c795ba11891ec2c1af3649eb65ead31a Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:54:18 -0700 Subject: [PATCH 047/130] mege hasContent into submit --- 4chan_x.user.js | 5 +---- script.coffee | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 11209e783..af9f135f2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1383,9 +1383,6 @@ ta.setSelectionRange(l, l); return ta.focus(); }, - hasContent: function() { - return $('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length; - }, keydown: function(e) { if (!(e.keyCode === 13 && this.value)) { return; @@ -1448,7 +1445,7 @@ }, submit: function(e) { var captcha, challenge, el, qr, response; - if (!QR.hasContent()) { + if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) { if (e) { alert('Error: No text entered.'); } diff --git a/script.coffee b/script.coffee index ab379d067..6a775ec7d 100644 --- a/script.coffee +++ b/script.coffee @@ -1089,8 +1089,6 @@ QR = l = text.length ta.setSelectionRange l, l ta.focus() - hasContent: -> - $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length keydown: (e) -> return unless e.keyCode is 13 and @value #enter, captcha filled QR.captchaPush @ @@ -1135,8 +1133,8 @@ QR = QR.attachNext() submit: (e) -> #XXX e is undefined if method is called explicitly, eg, from auto posting - unless QR.hasContent() - alert 'Error: No text entered.' if e #don't alert at the end of auto posting + unless $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length + alert 'Error: No text entered.' if e #only alert if explicitly submitting return {qr} = QR $('.error', qr).textContent = '' From 8a5bbe2b54b04deb0a25a5530c9a04598bb906a2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:55:32 -0700 Subject: [PATCH 048/130] el -> qr --- 4chan_x.user.js | 6 +++--- script.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index af9f135f2..9ff1c0359 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1367,9 +1367,9 @@ left: '0' }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); c = d.cookie; - $('[name=name]', el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('[name=email]', el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('[name=pwd]', el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; + $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; if (conf['Cooldown']) { QR.cooldown; } diff --git a/script.coffee b/script.coffee index 6a775ec7d..54d887315 100644 --- a/script.coffee +++ b/script.coffee @@ -1076,9 +1076,9 @@ QR = " #XXX use dom methods to set values instead of injecting raw user input into your html -_-; c = d.cookie - $('[name=name]', el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=email]', el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=pwd]', el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value QR.cooldown if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit From 4de10a54d2fb5eb782123979d9b51a15db673786 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:56:56 -0700 Subject: [PATCH 049/130] preventdefault --- 4chan_x.user.js | 1 + script.coffee | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9ff1c0359..6e99af92d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1448,6 +1448,7 @@ if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) { if (e) { alert('Error: No text entered.'); + e.preventDefault(); } return; } diff --git a/script.coffee b/script.coffee index 54d887315..91ca58fca 100644 --- a/script.coffee +++ b/script.coffee @@ -1134,7 +1134,9 @@ QR = submit: (e) -> #XXX e is undefined if method is called explicitly, eg, from auto posting unless $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length - alert 'Error: No text entered.' if e #only alert if explicitly submitting + if e + alert 'Error: No text entered.' + e.preventDefault() return {qr} = QR $('.error', qr).textContent = '' From a6693e9f3a45d131a536ad3b295ba61cdc392052 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 13:17:02 -0700 Subject: [PATCH 050/130] derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6e99af92d..339866d14 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1389,7 +1389,7 @@ } QR.captchaPush(this); e.preventDefault(); - return e.submit(); + return QR.submit(); }, quote: function(e) { var i, ss, ta, text, v; diff --git a/script.coffee b/script.coffee index 91ca58fca..e0bae4fcc 100644 --- a/script.coffee +++ b/script.coffee @@ -1093,7 +1093,7 @@ QR = return unless e.keyCode is 13 and @value #enter, captcha filled QR.captchaPush @ e.preventDefault() - e.submit() #derpy, but prevents calling QR.hasContent twice + QR.submit() #derpy, but prevents calling QR.hasContent twice quote: (e) -> e.preventDefault() text = ">>#{@textContent}\n" From a10cac59f799b7a3822e419c164fbb598d2955ed Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 13:38:07 -0700 Subject: [PATCH 051/130] selection --- 4chan_x.user.js | 17 +++++++++++++---- script.coffee | 13 ++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 339866d14..5ebabced5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1392,14 +1392,23 @@ return QR.submit(); }, quote: function(e) { - var i, ss, ta, text, v; + var i, id, qr, s, sel, ss, ta, text, v, _ref; e.preventDefault(); - text = ">>" + this.textContent + "\n"; - if (!QR.qr) { + id = this.textContent; + text = ">>" + id + "\n"; + sel = getSelection(); + if (id === ((_ref = $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)) != null ? _ref.name : void 0)) { + if (s = sel.toString().replace(/\n/g, '\n>')) { + text += ">" + s + "\n"; + } + } + qr = QR.qr; + if (!qr) { QR.dialog(text); return; } - ta = $('textarea', QR.qr); + $('#autohide', qr).checked = false; + ta = $('textarea', qr); v = ta.value; ss = ta.selectionStart; ta.value = v.slice(0, ss) + text + v.slice(ss); diff --git a/script.coffee b/script.coffee index e0bae4fcc..d58d1a4e6 100644 --- a/script.coffee +++ b/script.coffee @@ -1096,11 +1096,18 @@ QR = QR.submit() #derpy, but prevents calling QR.hasContent twice quote: (e) -> e.preventDefault() - text = ">>#{@textContent}\n" - if not QR.qr + id = @textContent + text = ">>#{id}\n" + sel = getSelection() + if id == $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)?.name + if s = sel.toString().replace /\n/g, '\n>' + text += ">#{s}\n" + {qr} = QR + if not qr QR.dialog text return - ta = $ 'textarea', QR.qr + $('#autohide', qr).checked = false + ta = $ 'textarea', qr v = ta.value ss = ta.selectionStart ta.value = v[0...ss] + text + v[ss..] From daa1e0da3ae1e8f635e6a51ddeb489df155055d4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 13:41:04 -0700 Subject: [PATCH 052/130] fix captcha img derp --- 4chan_x.user.js | 4 +++- script.coffee | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5ebabced5..7354071b0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1294,7 +1294,9 @@ captchaNode: function(e) { var c; c = e.target.value; - $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; + if (QR.qr) { + $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; + } return QR.captcha = { challenge: c, time: Date.now() diff --git a/script.coffee b/script.coffee index d58d1a4e6..52eb23c83 100644 --- a/script.coffee +++ b/script.coffee @@ -1010,7 +1010,7 @@ QR = $.replace oldFile, file captchaNode: (e) -> c = e.target.value - $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" + $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr QR.captcha = challenge: c time: Date.now() From bc62b6524c3c94a1c0bdd0538a99f6184206869b Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 13:45:38 -0700 Subject: [PATCH 053/130] auto watch reply --- 4chan_x.user.js | 11 +++++++++-- script.coffee | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7354071b0..822cfdf33 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1455,7 +1455,7 @@ return QR.attachNext(); }, submit: function(e) { - var captcha, challenge, el, qr, response; + var captcha, challenge, el, id, op, qr, response; if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) { if (e) { alert('Error: No text entered.'); @@ -1484,7 +1484,14 @@ if (!e) { $('#qr_form', qr).submit(); } - return QR.sage = /sage/i.test($('[name=email]', qr).value); + QR.sage = /sage/i.test($('[name=email]', qr).value); + if (conf['Thread Watcher'] && conf['Auto Watch Reply']) { + id = $('input[name=resto]', qr.el).value; + op = $.id(id); + if ($('img.favicon', op).src === Favicon.empty) { + return watcher.watch(op, id); + } + } }, sys: function() { return $.globalEval(function() { diff --git a/script.coffee b/script.coffee index 52eb23c83..914397a27 100644 --- a/script.coffee +++ b/script.coffee @@ -1159,6 +1159,11 @@ QR = $('#autohide', qr).checked = true if conf['Auto Hide QR'] $('#qr_form', qr).submit() if not e QR.sage = /sage/i.test $('[name=email]', qr).value + if conf['Thread Watcher'] and conf['Auto Watch Reply'] + id = $('input[name=resto]', qr.el).value + op = $.id id + if $('img.favicon', op).src is Favicon.empty + watcher.watch op, id sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild From 98a1f8a6f4711af865deae4b4eeee2f4b72ead91 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 13:50:29 -0700 Subject: [PATCH 054/130] dom textarea, blank iframe on receipt, comments --- 4chan_x.user.js | 7 ++++--- script.coffee | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 822cfdf33..06ffe3de3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1367,11 +1367,12 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; + $('textarea', qr).value = text; if (conf['Cooldown']) { QR.cooldown; } @@ -1420,6 +1421,7 @@ }, receive: function(e) { var data, tc, _ref; + $('iframe[name=iframe]').src = 'about:blank'; data = e.data; if (data) { data = JSON.parse(data); @@ -1503,8 +1505,7 @@ href: href }); } - parent.postMessage(data, '*'); - return window.location = 'about:blank'; + return parent.postMessage(data, '*'); }); } }; diff --git a/script.coffee b/script.coffee index 914397a27..fbc705b0a 100644 --- a/script.coffee +++ b/script.coffee @@ -962,6 +962,9 @@ cooldown = QR = #FIXME DRY + #index reply + #create new thread + #sys normal post form fallback init: -> g.callbacks.push (root) -> quote = $ 'a.quotejs + a', root @@ -1065,7 +1068,7 @@ QR =
#{QR.spoiler}
-
+
#{$.get('captchas', []).length} captchas
@@ -1079,6 +1082,7 @@ QR = $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + $('textarea', qr).value = text QR.cooldown if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit @@ -1115,6 +1119,7 @@ QR = ta.setSelectionRange i, i ta.focus() receive: (e) -> + $('iframe[name=iframe]').src = 'about:blank' {data} = e if data data = JSON.parse data @@ -1170,7 +1175,6 @@ QR = {textContent, href} = node data = JSON.stringify {textContent, href} parent.postMessage data, '*' - window.location = 'about:blank' qr = # TODO From 83a15f88eff7e010de9efe3521541195f55ae832 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 14:07:38 -0700 Subject: [PATCH 055/130] index reply --- 4chan_x.user.js | 9 +++++---- script.coffee | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 06ffe3de3..edbf6d546 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1359,7 +1359,7 @@ } } }, - dialog: function(text) { + dialog: function(text, tid) { var c, l, m, qr, ta; if (text == null) { text = ''; @@ -1367,7 +1367,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -1395,8 +1395,9 @@ return QR.submit(); }, quote: function(e) { - var i, id, qr, s, sel, ss, ta, text, v, _ref; + var i, id, qr, s, sel, ss, ta, text, tid, v, _ref; e.preventDefault(); + tid = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', this).id; id = this.textContent; text = ">>" + id + "\n"; sel = getSelection(); @@ -1407,7 +1408,7 @@ } qr = QR.qr; if (!qr) { - QR.dialog(text); + QR.dialog(text, tid); return; } $('#autohide', qr).checked = false; diff --git a/script.coffee b/script.coffee index fbc705b0a..1caae9e68 100644 --- a/script.coffee +++ b/script.coffee @@ -961,9 +961,8 @@ cooldown = qr.autoPost() QR = + #TODO create new thread #FIXME DRY - #index reply - #create new thread #sys normal post form fallback init: -> g.callbacks.push (root) -> @@ -1057,12 +1056,12 @@ QR = textContent: 'Submit' disabled: false QR.submit() if $('#auto', QR.qr).checked - dialog: (text='') -> + dialog: (text='', tid) -> QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " X
Quick Reply
- + @@ -1100,6 +1099,7 @@ QR = QR.submit() #derpy, but prevents calling QR.hasContent twice quote: (e) -> e.preventDefault() + tid = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', @).id id = @textContent text = ">>#{id}\n" sel = getSelection() @@ -1108,7 +1108,7 @@ QR = text += ">#{s}\n" {qr} = QR if not qr - QR.dialog text + QR.dialog text, tid return $('#autohide', qr).checked = false ta = $ 'textarea', qr From b14178653218406f64859424b3c4ef55344cb89f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 14:13:03 -0700 Subject: [PATCH 056/130] class=inputtext --- 4chan_x.user.js | 2 +- script.coffee | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index edbf6d546..a50fd0e19 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1367,7 +1367,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 1caae9e68..1eb0a6aac 100644 --- a/script.coffee +++ b/script.coffee @@ -1059,21 +1059,21 @@ QR = dialog: (text='', tid) -> QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " X -
Quick Reply
+
Quick Reply
-
#{QR.spoiler}
-
-
+
#{QR.spoiler}
+
+
-
#{$.get('captchas', []).length} captchas
+
#{$.get('captchas', []).length} captchas
- + " #XXX use dom methods to set values instead of injecting raw user input into your html -_-; From 3e24845afb77b448970a056b11efc53b45351d55 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 14:38:58 -0700 Subject: [PATCH 057/130] sys stuff --- 4chan_x.user.js | 45 ++++++++++++++++++++++++++++++++++++++------- script.coffee | 34 +++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a50fd0e19..ce6777ee5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1227,7 +1227,7 @@ }; QR = { init: function() { - var accept, holder; + var accept, holder, m; g.callbacks.push(function(root) { var quote; quote = $('a.quotejs + a', root); @@ -1259,9 +1259,14 @@ if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { - return $('#autohide', QR.qr).checked = true; + $('#autohide', QR.qr).checked = true; } } + if (conf['Cooldown'] && (m = location.search.match(/cooldown=(\d+)/))) { + cooldown = m[1]; + $.set("cooldown/" + g.BOARD, cooldown); + return QR.cooldown(); + } }, attach: function() { var div, file; @@ -1374,7 +1379,7 @@ $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; $('textarea', qr).value = text; if (conf['Cooldown']) { - QR.cooldown; + QR.cooldown(); } $.bind($('.close', qr), 'click', QR.close); $.bind($('form', qr), 'submit', QR.submit); @@ -1497,7 +1502,12 @@ } }, sys: function() { - return $.globalEval(function() { + var c, duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref, _ref2; + if (recaptcha = $('#recaptcha_response_field')) { + $.bind(recaptcha, 'keydown', Recaptcha.listener); + return; + } + $.globalEval(function() { var data, href, node, textContent, _ref; if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) { textContent = node.textContent, href = node.href; @@ -1508,6 +1518,30 @@ } return parent.postMessage(data, '*'); }); + if (!((c = (_ref = $('b')) != null ? _ref.lastChild : void 0) && c.nodeType === 8)) { + return; + } + _ref2 = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref2[0], thread = _ref2[1], id = _ref2[2]; + search = location.search; + cooldown = /cooldown/.test(search); + noko = /noko/.test(search); + sage = /sage/.test(search); + watch = /watch/.test(search); + url = "http://boards.4chan.org/" + g.BOARD; + if (watch && thread === '0') { + url += "/res/" + id + "?watch"; + } else if (noko) { + url += '/res/'; + url += thread === '0' ? id : thread; + } + if (cooldown) { + duration = Date.now() + (sage ? 60 : 30) * 1000; + url += '?cooldown=' + duration; + } + if (noko) { + url += '#' + id; + } + return window.location = url; } }; qr = { @@ -3125,9 +3159,6 @@ if (conf['Auto Noko'] && canPost) { form.action += '?noko'; } - if (conf['Cooldown'] && canPost) { - cooldown.init(); - } if (conf['Image Expansion']) { imgExpand.init(); } diff --git a/script.coffee b/script.coffee index 1eb0a6aac..92e5a9721 100644 --- a/script.coffee +++ b/script.coffee @@ -962,8 +962,9 @@ cooldown = QR = #TODO create new thread + #captcha caching for report form + #report queueing #FIXME DRY - #sys normal post form fallback init: -> g.callbacks.push (root) -> quote = $ 'a.quotejs + a', root @@ -991,6 +992,10 @@ QR = QR.dialog() if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true + if conf['Cooldown'] and m = location.search.match /cooldown=(\d+)/ + cooldown = m[1] + $.set "cooldown/#{g.BOARD}", cooldown + QR.cooldown() attach: -> $('#auto', QR.qr).checked = true div = $.el 'div', @@ -1082,7 +1087,7 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text - QR.cooldown if conf['Cooldown'] + QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown @@ -1170,11 +1175,33 @@ QR = if $('img.favicon', op).src is Favicon.empty watcher.watch op, id sys: -> + if recaptcha = $ '#recaptcha_response_field' #post reporting + $.bind recaptcha, 'keydown', Recaptcha.listener + return $.globalEval -> if node = document.querySelector('table font b')?.firstChild {textContent, href} = node data = JSON.stringify {textContent, href} parent.postMessage data, '*' + return unless (c = $('b')?.lastChild) and c.nodeType is 8 #comment node + [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) + {search} = location + cooldown = /cooldown/.test search + noko = /noko/ .test search + sage = /sage/ .test search + watch = /watch/ .test search + url = "http://boards.4chan.org/#{g.BOARD}" + if watch and thread is '0' + url += "/res/#{id}?watch" + else if noko + url += '/res/' + url += if thread is '0' then id else thread + if cooldown + duration = Date.now() + (if sage then 60 else 30) * 1000 + url += '?cooldown=' + duration + if noko + url += '#' + id + window.location = url qr = # TODO @@ -2448,9 +2475,6 @@ main = if conf['Auto Noko'] and canPost form.action += '?noko' - if conf['Cooldown'] and canPost - cooldown.init() - if conf['Image Expansion'] imgExpand.init() From d60d214f1b3e87dbe85af7d0b67fa4aad471b05a Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 14:48:43 -0700 Subject: [PATCH 058/130] data --- 4chan_x.user.js | 6 +++--- script.coffee | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ce6777ee5..3c0218017 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1502,7 +1502,7 @@ } }, sys: function() { - var c, duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref, _ref2; + var duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref; if (recaptcha = $('#recaptcha_response_field')) { $.bind(recaptcha, 'keydown', Recaptcha.listener); return; @@ -1518,10 +1518,10 @@ } return parent.postMessage(data, '*'); }); - if (!((c = (_ref = $('b')) != null ? _ref.lastChild : void 0) && c.nodeType === 8)) { + if (!(d = $('b').lastChild.data)) { return; } - _ref2 = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref2[0], thread = _ref2[1], id = _ref2[2]; + _ref = d.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; search = location.search; cooldown = /cooldown/.test(search); noko = /noko/.test(search); diff --git a/script.coffee b/script.coffee index 92e5a9721..d95bb2357 100644 --- a/script.coffee +++ b/script.coffee @@ -1183,8 +1183,8 @@ QR = {textContent, href} = node data = JSON.stringify {textContent, href} parent.postMessage data, '*' - return unless (c = $('b')?.lastChild) and c.nodeType is 8 #comment node - [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) + return unless d = $('b').lastChild.data #comment + [_, thread, id] = d.match(/thread:(\d+),no:(\d+)/) {search} = location cooldown = /cooldown/.test search noko = /noko/ .test search From ee040e52ada4efb6650889c723f220180f299384 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 15:07:15 -0700 Subject: [PATCH 059/130] max file size --- 4chan_x.user.js | 10 ++++++++-- script.coffee | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3c0218017..b7ec7269d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1255,6 +1255,7 @@ } }); QR.accept = "'" + accept + "'"; + QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = $('.postarea label') ? ' ' : ''; if (conf['Persistent QR']) { QR.dialog(); @@ -1332,8 +1333,13 @@ return captcha; }, change: function() { - $.unbind(this, 'change', QR.change); - return QR.attach(); + if (this.files[0].size > QR.MAX_FILE_SIZE) { + alert('Error: File too large.'); + return this.click(); + } else { + $.unbind(this, 'change', QR.change); + return QR.attach(); + } }, close: function() { $.rm(QR.qr); diff --git a/script.coffee b/script.coffee index d95bb2357..48785a622 100644 --- a/script.coffee +++ b/script.coffee @@ -987,6 +987,7 @@ QR = else 'image/' + type QR.accept = "'#{accept}'" + QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value QR.spoiler = if $('.postarea label') then ' ' else '' if conf['Persistent QR'] QR.dialog() @@ -1040,8 +1041,12 @@ QR = $('#cl', QR.qr).textContent = captchas.length + ' captchas' captcha change: -> - $.unbind @, 'change', QR.change - QR.attach() + if @files[0].size > QR.MAX_FILE_SIZE + alert 'Error: File too large.' + @.click() + else + $.unbind @, 'change', QR.change + QR.attach() close: -> $.rm QR.qr QR.qr = null From 37f8c16c885bb8a163b28241b07e33ccab5c26a8 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 15:30:44 -0700 Subject: [PATCH 060/130] quote keybind --- 4chan_x.user.js | 18 +++++++++++------- script.coffee | 15 ++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b7ec7269d..2aa85fa41 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -907,17 +907,19 @@ } }, qr: function(thread, quote) { - var qrLink; + var qrLink, tid; if (!(qrLink = $('td.replyhl span[id] a:not(:first-child)', thread))) { qrLink = $("span[id^=nothread] a:not(:first-child)", thread); } + tid = g.THREAD_ID || thread.firstChild.id; if (quote) { - return qr.quote.call(qrLink); + return QR.quote.call(qrLink); } else { - if (!qr.el) { - qr.dialog(qrLink); + if (QR.qr) { + return $('textarea', QR.qr).focus(); + } else { + return QR.dialog('', tid); } - return $('textarea', qr.el).focus(); } }, open: function(thread, tab) { @@ -1405,9 +1407,11 @@ e.preventDefault(); return QR.submit(); }, - quote: function(e) { + quote: function(e, blank) { var i, id, qr, s, sel, ss, ta, text, tid, v, _ref; - e.preventDefault(); + if (e != null) { + e.preventDefault(); + } tid = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', this).id; id = this.textContent; text = ">>" + id + "\n"; diff --git a/script.coffee b/script.coffee index 48785a622..15140d794 100644 --- a/script.coffee +++ b/script.coffee @@ -652,13 +652,14 @@ keybinds = qr: (thread, quote) -> unless qrLink = $ 'td.replyhl span[id] a:not(:first-child)', thread qrLink = $ "span[id^=nothread] a:not(:first-child)", thread - + tid = g.THREAD_ID or thread.firstChild.id if quote - qr.quote.call qrLink + QR.quote.call qrLink else - unless qr.el - qr.dialog qrLink - $('textarea', qr.el).focus() + if QR.qr + $('textarea', QR.qr).focus() + else + QR.dialog '', tid open: (thread, tab) -> id = thread.firstChild.id @@ -1107,8 +1108,8 @@ QR = QR.captchaPush @ e.preventDefault() QR.submit() #derpy, but prevents calling QR.hasContent twice - quote: (e) -> - e.preventDefault() + quote: (e, blank) -> + e?.preventDefault() tid = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', @).id id = @textContent text = ">>#{id}\n" From 8d5c2821102819b45678ad9a9e858138f022ab70 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 16:04:44 -0700 Subject: [PATCH 061/130] refactor --- 4chan_x.user.js | 9 ++------- script.coffee | 7 ++----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2aa85fa41..d0f808f53 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -907,18 +907,13 @@ } }, qr: function(thread, quote) { - var qrLink, tid; - if (!(qrLink = $('td.replyhl span[id] a:not(:first-child)', thread))) { - qrLink = $("span[id^=nothread] a:not(:first-child)", thread); - } - tid = g.THREAD_ID || thread.firstChild.id; if (quote) { - return QR.quote.call(qrLink); + return QR.quote.call($('a.quotejs + a', $('td.replyhl', thread) || thread)); } else { if (QR.qr) { return $('textarea', QR.qr).focus(); } else { - return QR.dialog('', tid); + return QR.dialog('', g.THREAD_ID || thread.firstChild.id); } } }, diff --git a/script.coffee b/script.coffee index 15140d794..753fc1754 100644 --- a/script.coffee +++ b/script.coffee @@ -650,16 +650,13 @@ keybinds = imgExpand.toggle thumb.parentNode qr: (thread, quote) -> - unless qrLink = $ 'td.replyhl span[id] a:not(:first-child)', thread - qrLink = $ "span[id^=nothread] a:not(:first-child)", thread - tid = g.THREAD_ID or thread.firstChild.id if quote - QR.quote.call qrLink + QR.quote.call $ 'a.quotejs + a', $('td.replyhl', thread) or thread else if QR.qr $('textarea', QR.qr).focus() else - QR.dialog '', tid + QR.dialog '', g.THREAD_ID or thread.firstChild.id open: (thread, tab) -> id = thread.firstChild.id From f096221f2fd948a41882e328acd430d6cc21220c Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 16:43:08 -0700 Subject: [PATCH 062/130] QR.file --- 4chan_x.user.js | 42 +++++++++++++++++++++++++----------------- script.coffee | 34 +++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d0f808f53..bf3807615 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1254,6 +1254,7 @@ QR.accept = "'" + accept + "'"; QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = $('.postarea label') ? ' ' : ''; + QR.file = ""; if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { @@ -1270,7 +1271,7 @@ var div, file; $('#auto', QR.qr).checked = true; div = $.el('div', { - innerHTML: "X" + innerHTML: "" + QR.file + "X" }); file = $('input', div); $.bind(file, 'change', QR.change); @@ -1281,18 +1282,14 @@ return file.click(); }, attachNext: function() { - var file, oldFile; - oldFile = $('[type=file]', QR.qr); + var file, old; + old = $('[type=file]', QR.qr); if (file = $('#files input', QR.qr)) { $.rm(file.parentNode); + return $.replace(old, file); } else { - file = $.el('input', { - type: 'file', - name: 'upfile', - accept: QR.accept - }); + return $.refreshFile(old); } - return $.replace(oldFile, file); }, captchaNode: function(e) { var c; @@ -1329,14 +1326,25 @@ $('#cl', QR.qr).textContent = captchas.length + ' captchas'; return captcha; }, - change: function() { - if (this.files[0].size > QR.MAX_FILE_SIZE) { - alert('Error: File too large.'); - return this.click(); - } else { - $.unbind(this, 'change', QR.change); - return QR.attach(); + change: function(e) { + if (!(this.files[0].size > QR.MAX_FILE_SIZE)) { + return; } + alert('Error: File too large.'); + return QR.refreshFile(this); + }, + refreshFile: function(old) { + var div, file; + div = $.el('div', { + innerHTML: QR.file + }); + file = div.firstChild; + $.bind(file, 'change', QR.change); + return $.replace(old, file); + }, + change1: function() { + $.unbind(this, 'change', QR.change); + return QR.attach(); }, close: function() { $.rm(QR.qr); @@ -1375,7 +1383,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
" + QR.file + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 753fc1754..fc2b5b5bb 100644 --- a/script.coffee +++ b/script.coffee @@ -987,6 +987,7 @@ QR = QR.accept = "'#{accept}'" QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value QR.spoiler = if $('.postarea label') then ' ' else '' + QR.file = "" if conf['Persistent QR'] QR.dialog() if conf['Auto Hide QR'] @@ -998,22 +999,19 @@ QR = attach: -> $('#auto', QR.qr).checked = true div = $.el 'div', - innerHTML: "X" + innerHTML: "#{QR.file}X" file = $ 'input', div $.bind file, 'change', QR.change $.bind $('a', div), 'click', -> $.rm @parentNode $.append $('#files', QR.qr), div file.click() attachNext: -> - oldFile = $ '[type=file]', QR.qr + old = $ '[type=file]', QR.qr if file = $ '#files input', QR.qr $.rm file.parentNode + $.replace old, file else - file = $.el 'input', - type: 'file' - name: 'upfile' - accept: QR.accept - $.replace oldFile, file + $.refreshFile old captchaNode: (e) -> c = e.target.value $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr @@ -1038,13 +1036,19 @@ QR = $.set 'captchas', captchas $('#cl', QR.qr).textContent = captchas.length + ' captchas' captcha - change: -> - if @files[0].size > QR.MAX_FILE_SIZE - alert 'Error: File too large.' - @.click() - else - $.unbind @, 'change', QR.change - QR.attach() + change: (e) -> + return unless @files[0].size > QR.MAX_FILE_SIZE + alert 'Error: File too large.' + QR.refreshFile @ + refreshFile: (old) -> + div = $.el 'div' + innerHTML: QR.file + file = div.firstChild + $.bind file, 'change', QR.change + $.replace old, file + change1: -> + $.unbind @, 'change', QR.change + QR.attach() close: -> $.rm QR.qr QR.qr = null @@ -1078,7 +1082,7 @@ QR =
#{$.get('captchas', []).length} captchas
-
+
#{QR.file}
From 65af9d0625479db458094f728d9afb3fd402a32f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 16:53:27 -0700 Subject: [PATCH 063/130] bind, click --- 4chan_x.user.js | 4 +++- script.coffee | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bf3807615..f98dfbdac 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1331,7 +1331,8 @@ return; } alert('Error: File too large.'); - return QR.refreshFile(this); + QR.refreshFile(this); + return $('[type=file]', QR.qr).click(); }, refreshFile: function(old) { var div, file; @@ -1395,6 +1396,7 @@ $.bind($('.close', qr), 'click', QR.close); $.bind($('form', qr), 'submit', QR.submit); $.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown); + $.bind($('[type=file]', qr), 'change', QR.change); $.bind($('#attach', qr), 'click', QR.attach); $.append(d.body, qr); ta = $('textarea', qr); diff --git a/script.coffee b/script.coffee index fc2b5b5bb..50635b028 100644 --- a/script.coffee +++ b/script.coffee @@ -1040,6 +1040,7 @@ QR = return unless @files[0].size > QR.MAX_FILE_SIZE alert 'Error: File too large.' QR.refreshFile @ + $('[type=file]', QR.qr).click() refreshFile: (old) -> div = $.el 'div' innerHTML: QR.file @@ -1098,6 +1099,7 @@ QR = $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown + $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach $.append d.body, qr ta = $ 'textarea', qr From 234c9faae30aed3b874d4af3af46f94f039fbfc2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 16:58:35 -0700 Subject: [PATCH 064/130] change1 --- 4chan_x.user.js | 3 ++- script.coffee | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f98dfbdac..62d98e36e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1275,6 +1275,7 @@ }); file = $('input', div); $.bind(file, 'change', QR.change); + $.bind(file, 'change', QR.change1); $.bind($('a', div), 'click', function() { return $.rm(this.parentNode); }); @@ -1344,7 +1345,7 @@ return $.replace(old, file); }, change1: function() { - $.unbind(this, 'change', QR.change); + $.unbind(this, 'change', QR.change1); return QR.attach(); }, close: function() { diff --git a/script.coffee b/script.coffee index 50635b028..a21320021 100644 --- a/script.coffee +++ b/script.coffee @@ -1002,6 +1002,7 @@ QR = innerHTML: "#{QR.file}X" file = $ 'input', div $.bind file, 'change', QR.change + $.bind file, 'change', QR.change1 $.bind $('a', div), 'click', -> $.rm @parentNode $.append $('#files', QR.qr), div file.click() @@ -1048,7 +1049,7 @@ QR = $.bind file, 'change', QR.change $.replace old, file change1: -> - $.unbind @, 'change', QR.change + $.unbind @, 'change', QR.change1 QR.attach() close: -> $.rm QR.qr From 34daa5fd2f1a9bf0fb934f31b8c69a2bbc79aa70 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 17:27:50 -0700 Subject: [PATCH 065/130] merge change1 into change, refreshFile -> resetFile --- 4chan_x.user.js | 41 +++++++++++++++++++++-------------------- script.coffee | 31 ++++++++++++++++--------------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 62d98e36e..134dfcb87 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1275,7 +1275,6 @@ }); file = $('input', div); $.bind(file, 'change', QR.change); - $.bind(file, 'change', QR.change1); $.bind($('a', div), 'click', function() { return $.rm(this.parentNode); }); @@ -1289,7 +1288,7 @@ $.rm(file.parentNode); return $.replace(old, file); } else { - return $.refreshFile(old); + return $.resetFile(old); } }, captchaNode: function(e) { @@ -1328,25 +1327,18 @@ return captcha; }, change: function(e) { - if (!(this.files[0].size > QR.MAX_FILE_SIZE)) { - return; + var a, p; + if (this.files[0].size > QR.MAX_FILE_SIZE) { + alert('Error: File too large.'); + QR.resetFile(this); + return $('[type=file]', QR.qr).click(); + } else { + p = this.parentNode; + a = p.parentNode; + if (a.id === 'files' && !p.nextSibling) { + return QR.attach(); + } } - alert('Error: File too large.'); - QR.refreshFile(this); - return $('[type=file]', QR.qr).click(); - }, - refreshFile: function(old) { - var div, file; - div = $.el('div', { - innerHTML: QR.file - }); - file = div.firstChild; - $.bind(file, 'change', QR.change); - return $.replace(old, file); - }, - change1: function() { - $.unbind(this, 'change', QR.change1); - return QR.attach(); }, close: function() { $.rm(QR.qr); @@ -1478,6 +1470,15 @@ $('textarea', QR.qr).value = ''; return QR.attachNext(); }, + resetFile: function(old) { + var div, file; + div = $.el('div', { + innerHTML: QR.file + }); + file = div.firstChild; + $.bind(file, 'change', QR.change); + return $.replace(old, file); + }, submit: function(e) { var captcha, challenge, el, id, op, qr, response; if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) { diff --git a/script.coffee b/script.coffee index a21320021..3238f9372 100644 --- a/script.coffee +++ b/script.coffee @@ -1002,7 +1002,6 @@ QR = innerHTML: "#{QR.file}X" file = $ 'input', div $.bind file, 'change', QR.change - $.bind file, 'change', QR.change1 $.bind $('a', div), 'click', -> $.rm @parentNode $.append $('#files', QR.qr), div file.click() @@ -1012,7 +1011,7 @@ QR = $.rm file.parentNode $.replace old, file else - $.refreshFile old + $.resetFile old captchaNode: (e) -> c = e.target.value $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr @@ -1038,19 +1037,15 @@ QR = $('#cl', QR.qr).textContent = captchas.length + ' captchas' captcha change: (e) -> - return unless @files[0].size > QR.MAX_FILE_SIZE - alert 'Error: File too large.' - QR.refreshFile @ - $('[type=file]', QR.qr).click() - refreshFile: (old) -> - div = $.el 'div' - innerHTML: QR.file - file = div.firstChild - $.bind file, 'change', QR.change - $.replace old, file - change1: -> - $.unbind @, 'change', QR.change1 - QR.attach() + if @files[0].size > QR.MAX_FILE_SIZE + alert 'Error: File too large.' + QR.resetFile @ + $('[type=file]', QR.qr).click() + else + p = @parentNode + a = p.parentNode + if a.id is 'files' and not p.nextSibling + QR.attach() close: -> $.rm QR.qr QR.qr = null @@ -1158,6 +1153,12 @@ QR = $('[name=spoiler]', QR.qr)?.checked = false unless conf['Remember Spoiler'] $('textarea', QR.qr).value = '' QR.attachNext() + resetFile: (old) -> + div = $.el 'div' + innerHTML: QR.file + file = div.firstChild + $.bind file, 'change', QR.change + $.replace old, file submit: (e) -> #XXX e is undefined if method is called explicitly, eg, from auto posting unless $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length From 698d146c63e48ec98f57133157a7da73b275fa8b Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 17:30:37 -0700 Subject: [PATCH 066/130] selector --- 4chan_x.user.js | 5 +---- script.coffee | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 134dfcb87..d181dd1b9 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1327,15 +1327,12 @@ return captcha; }, change: function(e) { - var a, p; if (this.files[0].size > QR.MAX_FILE_SIZE) { alert('Error: File too large.'); QR.resetFile(this); return $('[type=file]', QR.qr).click(); } else { - p = this.parentNode; - a = p.parentNode; - if (a.id === 'files' && !p.nextSibling) { + if (this === $('#files div:last-of-type input', QR.qr)) { return QR.attach(); } } diff --git a/script.coffee b/script.coffee index 3238f9372..495774333 100644 --- a/script.coffee +++ b/script.coffee @@ -1042,9 +1042,7 @@ QR = QR.resetFile @ $('[type=file]', QR.qr).click() else - p = @parentNode - a = p.parentNode - if a.id is 'files' and not p.nextSibling + if @ is $('#files div:last-of-type input', QR.qr) QR.attach() close: -> $.rm QR.qr From c2754bcb9975c80d114f695fb7ddce4d23bb8075 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 17:55:27 -0700 Subject: [PATCH 067/130] backspace captcha --- 4chan_x.user.js | 1 + script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index d181dd1b9..ba73053f6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1386,6 +1386,7 @@ $.bind($('.close', qr), 'click', QR.close); $.bind($('form', qr), 'submit', QR.submit); $.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown); + $.bind($('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener); $.bind($('[type=file]', qr), 'change', QR.change); $.bind($('#attach', qr), 'click', QR.attach); $.append(d.body, qr); diff --git a/script.coffee b/script.coffee index 495774333..af14ef85c 100644 --- a/script.coffee +++ b/script.coffee @@ -1093,6 +1093,7 @@ QR = $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown + $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach $.append d.body, qr From d1608b06462c3a584c19433dc33c117572e7a0b3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 18:02:54 -0700 Subject: [PATCH 068/130] derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ba73053f6..20d1f6938 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1288,7 +1288,7 @@ $.rm(file.parentNode); return $.replace(old, file); } else { - return $.resetFile(old); + return QR.resetFile(old); } }, captchaNode: function(e) { diff --git a/script.coffee b/script.coffee index af14ef85c..823119c01 100644 --- a/script.coffee +++ b/script.coffee @@ -1011,7 +1011,7 @@ QR = $.rm file.parentNode $.replace old, file else - $.resetFile old + QR.resetFile old captchaNode: (e) -> c = e.target.value $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr From 49d32b3d417d39620f5c10cd53cbfeaa4eaa9c01 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 22:34:32 -0700 Subject: [PATCH 069/130] merge QR.accept into QR.file --- 4chan_x.user.js | 3 +-- script.coffee | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 18001e12e..f2f69ce0e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1251,10 +1251,9 @@ return 'image/' + type; } }); - QR.accept = "'" + accept + "'"; + QR.file = ""; QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = $('.postarea label') ? ' ' : ''; - QR.file = ""; if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { diff --git a/script.coffee b/script.coffee index 0555a0125..0da5193e2 100644 --- a/script.coffee +++ b/script.coffee @@ -984,10 +984,9 @@ QR = 'application/' + type else 'image/' + type - QR.accept = "'#{accept}'" + QR.file = "" QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value QR.spoiler = if $('.postarea label') then ' ' else '' - QR.file = "" if conf['Persistent QR'] QR.dialog() if conf['Auto Hide QR'] From 9fd9fb9d05252f7fa9cfae31f3cf6e56d447de37 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 22:41:06 -0700 Subject: [PATCH 070/130] QR.captchaLength --- 4chan_x.user.js | 11 ++++++++--- script.coffee | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f2f69ce0e..6732f86d8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1310,7 +1310,7 @@ $.set('captchas', captchas); el.value = ''; Recaptcha.reload(); - return el.nextSibling.textContent = captchas.length + ' captchas'; + return captchaLength(captchas); }, captchaShift: function() { var captcha, captchas, cutoff; @@ -1322,9 +1322,13 @@ } } $.set('captchas', captchas); - $('#cl', QR.qr).textContent = captchas.length + ' captchas'; + captchaLength(captchas); return captcha; }, + captchaLength: function(captchas) { + captchas || (captchas = $.get('captchas', [])); + return $('#cl', QR.qr).textContent = captchas.length + ' captchas'; + }, change: function(e) { if (this.files[0].size > QR.MAX_FILE_SIZE) { alert('Error: File too large.'); @@ -1373,12 +1377,13 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + ($.get('captchas', []).length) + " captchas
" + QR.file + "
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + QR.file + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; $('textarea', qr).value = text; + QR.captchaLength(); if (conf['Cooldown']) { QR.cooldown(); } diff --git a/script.coffee b/script.coffee index 0da5193e2..70c753aaf 100644 --- a/script.coffee +++ b/script.coffee @@ -1025,7 +1025,7 @@ QR = $.set 'captchas', captchas el.value = '' Recaptcha.reload() - el.nextSibling.textContent = captchas.length + ' captchas' + captchaLength captchas captchaShift: -> captchas = $.get 'captchas', [] cutoff = Date.now() - 5*HOUR + 5*MINUTE @@ -1033,8 +1033,11 @@ QR = if captcha.time > cutoff break $.set 'captchas', captchas - $('#cl', QR.qr).textContent = captchas.length + ' captchas' + captchaLength captchas captcha + captchaLength: (captchas) -> + captchas or= $.get 'captchas', [] + $('#cl', QR.qr).textContent = captchas.length + ' captchas' change: (e) -> if @files[0].size > QR.MAX_FILE_SIZE alert 'Error: File too large.' @@ -1075,7 +1078,7 @@ QR =
-
#{$.get('captchas', []).length} captchas
+
#{QR.file}
@@ -1088,6 +1091,7 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text + QR.captchaLength() QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close $.bind $('form', qr), 'submit', QR.submit From f205372b46a51e6b56ce65c6afa163bf29c70587 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 23:00:27 -0700 Subject: [PATCH 071/130] comments --- script.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script.coffee b/script.coffee index 70c753aaf..c2d3fd591 100644 --- a/script.coffee +++ b/script.coffee @@ -962,6 +962,7 @@ QR = #TODO create new thread #captcha caching for report form #report queueing + #check if captchas can be reused on eg dup file error #FIXME DRY init: -> g.callbacks.push (root) -> @@ -1108,7 +1109,7 @@ QR = return unless e.keyCode is 13 and @value #enter, captcha filled QR.captchaPush @ e.preventDefault() - QR.submit() #derpy, but prevents calling QR.hasContent twice + QR.submit() #derpy, but prevents checking for content twice quote: (e, blank) -> e?.preventDefault() tid = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', @).id @@ -1196,7 +1197,9 @@ QR = {textContent, href} = node data = JSON.stringify {textContent, href} parent.postMessage data, '*' - return unless d = $('b').lastChild.data #comment + #parent will blank us on message receival; + #if we're not an iframe, we won't get blanked + return unless d = $('b').lastChild.data #html comment [_, thread, id] = d.match(/thread:(\d+),no:(\d+)/) {search} = location cooldown = /cooldown/.test search From 5bbcee37ff2c30e174e3fcf206f6aa5fe93d970d Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 23:12:35 -0700 Subject: [PATCH 072/130] QR.captchaImg --- 4chan_x.user.js | 22 ++++++++++++++-------- script.coffee | 13 +++++++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6732f86d8..3cc5f1c32 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1291,15 +1291,20 @@ } }, captchaNode: function(e) { - var c; - c = e.target.value; - if (QR.qr) { - $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; - } - return QR.captcha = { - challenge: c, + QR.captcha = { + challenge: e.target.value, time: Date.now() }; + return QR.captchaImg(); + }, + captchaImg: function() { + var c, qr; + qr = QR.qr; + if (!qr) { + return; + } + c = QR.captcha.challenge; + return $('img', qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; }, captchaPush: function(el) { var captcha, captchas; @@ -1377,12 +1382,13 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + QR.file + "
"); + }, " X
Quick Reply
" + QR.spoiler + "
" + QR.file + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; $('textarea', qr).value = text; + QR.captchaImg(); QR.captchaLength(); if (conf['Cooldown']) { QR.cooldown(); diff --git a/script.coffee b/script.coffee index c2d3fd591..040b91457 100644 --- a/script.coffee +++ b/script.coffee @@ -1013,11 +1013,15 @@ QR = else QR.resetFile old captchaNode: (e) -> - c = e.target.value - $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr QR.captcha = - challenge: c + challenge: e.target.value time: Date.now() + QR.captchaImg() + captchaImg: -> + {qr} = QR + return unless qr + c = QR.captcha.challenge + $('img', qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" captchaPush: (el) -> {captcha} = QR captcha.response = el.value @@ -1078,7 +1082,7 @@ QR =
#{QR.spoiler}
-
+
#{QR.file}
@@ -1092,6 +1096,7 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text + QR.captchaImg() QR.captchaLength() QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close From e0212edafa47617029d741398184aab046ed7d13 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 23:15:06 -0700 Subject: [PATCH 073/130] dry enough --- script.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/script.coffee b/script.coffee index 040b91457..9295aabed 100644 --- a/script.coffee +++ b/script.coffee @@ -963,7 +963,6 @@ QR = #captcha caching for report form #report queueing #check if captchas can be reused on eg dup file error - #FIXME DRY init: -> g.callbacks.push (root) -> quote = $ 'a.quotejs + a', root From ea76eca01c6f01cfe08a0ef256bb4c97cf689ecf Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 23:21:26 -0700 Subject: [PATCH 074/130] strip location.search stuff --- 4chan_x.user.js | 37 ++++--------------------------------- script.coffee | 23 ----------------------- 2 files changed, 4 insertions(+), 56 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3cc5f1c32..ffc07c122 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1224,7 +1224,7 @@ }; QR = { init: function() { - var accept, holder, m; + var accept, holder; g.callbacks.push(function(root) { var quote; quote = $('a.quotejs + a', root); @@ -1257,14 +1257,9 @@ if (conf['Persistent QR']) { QR.dialog(); if (conf['Auto Hide QR']) { - $('#autohide', QR.qr).checked = true; + return $('#autohide', QR.qr).checked = true; } } - if (conf['Cooldown'] && (m = location.search.match(/cooldown=(\d+)/))) { - cooldown = m[1]; - $.set("cooldown/" + g.BOARD, cooldown); - return QR.cooldown(); - } }, attach: function() { var div, file; @@ -1527,12 +1522,12 @@ } }, sys: function() { - var duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref; + var recaptcha; if (recaptcha = $('#recaptcha_response_field')) { $.bind(recaptcha, 'keydown', Recaptcha.listener); return; } - $.globalEval(function() { + return $.globalEval(function() { var data, href, node, textContent, _ref; if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) { textContent = node.textContent, href = node.href; @@ -1543,30 +1538,6 @@ } return parent.postMessage(data, '*'); }); - if (!(d = $('b').lastChild.data)) { - return; - } - _ref = d.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; - search = location.search; - cooldown = /cooldown/.test(search); - noko = /noko/.test(search); - sage = /sage/.test(search); - watch = /watch/.test(search); - url = "http://boards.4chan.org/" + g.BOARD; - if (watch && thread === '0') { - url += "/res/" + id + "?watch"; - } else if (noko) { - url += '/res/'; - url += thread === '0' ? id : thread; - } - if (cooldown) { - duration = Date.now() + (sage ? 60 : 30) * 1000; - url += '?cooldown=' + duration; - } - if (noko) { - url += '#' + id; - } - return window.location = url; } }; qr = { diff --git a/script.coffee b/script.coffee index 9295aabed..170657b8b 100644 --- a/script.coffee +++ b/script.coffee @@ -991,10 +991,6 @@ QR = QR.dialog() if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true - if conf['Cooldown'] and m = location.search.match /cooldown=(\d+)/ - cooldown = m[1] - $.set "cooldown/#{g.BOARD}", cooldown - QR.cooldown() attach: -> $('#auto', QR.qr).checked = true div = $.el 'div', @@ -1203,25 +1199,6 @@ QR = parent.postMessage data, '*' #parent will blank us on message receival; #if we're not an iframe, we won't get blanked - return unless d = $('b').lastChild.data #html comment - [_, thread, id] = d.match(/thread:(\d+),no:(\d+)/) - {search} = location - cooldown = /cooldown/.test search - noko = /noko/ .test search - sage = /sage/ .test search - watch = /watch/ .test search - url = "http://boards.4chan.org/#{g.BOARD}" - if watch and thread is '0' - url += "/res/#{id}?watch" - else if noko - url += '/res/' - url += if thread is '0' then id else thread - if cooldown - duration = Date.now() + (if sage then 60 else 30) * 1000 - url += '?cooldown=' + duration - if noko - url += '#' + id - window.location = url qr = # TODO From 8caf096216b0e6773dd859f19d31e2632a2192dd Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 23:27:42 -0700 Subject: [PATCH 075/130] blur textarea on persistent qr damn that shit is annoying --- 4chan_x.user.js | 1 + script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index ffc07c122..e5726dccb 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1256,6 +1256,7 @@ QR.spoiler = $('.postarea label') ? ' ' : ''; if (conf['Persistent QR']) { QR.dialog(); + $('textarea', QR.qr).blur(); if (conf['Auto Hide QR']) { return $('#autohide', QR.qr).checked = true; } diff --git a/script.coffee b/script.coffee index 170657b8b..bfd3ee7c0 100644 --- a/script.coffee +++ b/script.coffee @@ -989,6 +989,7 @@ QR = QR.spoiler = if $('.postarea label') then ' ' else '' if conf['Persistent QR'] QR.dialog() + $('textarea', QR.qr).blur() if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true attach: -> From 13f23ef8558ea5b2df3fe67fdc3c99a0ffe5ecf7 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 01:17:12 -0700 Subject: [PATCH 076/130] start qr redesign --- 4chan_x.user.js | 127 +++++++++++++++++++++++++----------------------- script.coffee | 100 ++++++++++++++++++++------------------ 2 files changed, 119 insertions(+), 108 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e5726dccb..2ea3fdb0b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1371,30 +1371,51 @@ } }, dialog: function(text, tid) { - var c, l, m, qr, ta; + var l, qr, ta; if (text == null) { text = ''; } QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + QR.spoiler + "
" + QR.file + "
"); - c = d.cookie; - $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; - $('textarea', qr).value = text; + }, " X
120 Captchas
Derp
", { + /* + " + X +
Quick Reply
+
+ + + + +
#{QR.spoiler}
+
+
+
+
+
#{QR.file}
+
+
+ + + " + #XXX use dom methods to set values instead of injecting raw user input into your html -_-; + c = d.cookie + $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + $('textarea', qr).value = text + QR.captchaLength() + QR.cooldown() if conf['Cooldown'] + $.bind $('.close', qr), 'click', QR.close + $.bind $('form', qr), 'submit', QR.submit + $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown + $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener + $.bind $('[type=file]', qr), 'change', QR.change + $.bind $('#attach', qr), 'click', QR.attach + */ + }); QR.captchaImg(); - QR.captchaLength(); - if (conf['Cooldown']) { - QR.cooldown(); - } - $.bind($('.close', qr), 'click', QR.close); - $.bind($('form', qr), 'submit', QR.submit); - $.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown); - $.bind($('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener); - $.bind($('[type=file]', qr), 'change', QR.change); - $.bind($('#attach', qr), 'click', QR.attach); $.append(d.body, qr); ta = $('textarea', qr); l = text.length; @@ -3275,7 +3296,7 @@ div.dialog > div.move {\ cursor: move;\ }\ - label, a, .favicon, #qr img {\ + label, a, .favicon {\ cursor: pointer;\ }\ \ @@ -3285,9 +3306,6 @@ .error {\ color: red;\ }\ - #qr .error:not([href]) {\ - cursor: default;\ - }\ td.replyhider {\ vertical-align: top;\ }\ @@ -3365,47 +3383,6 @@ margin: 0;\ width: 100%;\ }\ -\ - #qr {\ - position: fixed;\ - max-height: 100%;\ - overflow-x: hidden;\ - overflow-y: auto;\ - }\ - #qr > div.move {\ - text-align: right;\ - }\ - #qr input[name=name] {\ - float: left;\ - }\ - #qr_form {\ - clear: left;\ - }\ - #qr_form, #qr #com_submit, #qr input[name=upfile] {\ - margin: 0;\ - }\ - #qr textarea {\ - width: 100%;\ - height: 125px;\ - }\ - #qr .close, #qr #autohide {\ - float: right;\ - }\ - #qr:not(:hover) > #autohide:checked ~ form {\ - height: 0;\ - overflow: hidden;\ - }\ - /* http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css */\ - #qr input::-webkit-input-placeholder {\ - color: grey;\ - }\ - #qr input:-moz-placeholder {\ - color: grey;\ - }\ - /* qr reCAPTCHA */\ - #qr img {\ - border: 1px solid #AAA;\ - }\ \ #updater {\ position: fixed;\ @@ -3471,6 +3448,32 @@ #files > input {\ display: block;\ }\ + #qr {\ + position: fixed;\ + }\ + #qr #autohide, #qr .close {\ + float: right;\ + }\ + #qr:not(:hover) #autohide:checked ~ .autohide {\ + height: 0;\ + overflow: hidden;\ + }\ + #qr textarea {\ + border: 0;\ + height: 125;\ + width: 100%;\ + }\ + #qr #captcha {\ + position: relative;\ + }\ + #qr #cl {\ + right: 0;\ + padding: 2px;\ + position: absolute;\ + }\ + #qr #recaptcha_response_field {\ + width: 100%;\ + }\ ' }; main.init(); diff --git a/script.coffee b/script.coffee index bfd3ee7c0..a14e8ce8a 100644 --- a/script.coffee +++ b/script.coffee @@ -1068,6 +1068,31 @@ QR = QR.submit() if $('#auto', QR.qr).checked dialog: (text='', tid) -> QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " + X + +
+ + Subject + Name + Email +
+
+ +
+
+ 120 Captchas + +
+
+ + + Derp +
+
+ " + + ### + " X
Quick Reply
@@ -1092,7 +1117,6 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text - QR.captchaImg() QR.captchaLength() QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close @@ -1101,6 +1125,8 @@ QR = $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach + ### + QR.captchaImg() $.append d.body, qr ta = $ 'textarea', qr l = text.length @@ -2580,7 +2606,7 @@ main = div.dialog > div.move { cursor: move; } - label, a, .favicon, #qr img { + label, a, .favicon { cursor: pointer; } @@ -2590,9 +2616,6 @@ main = .error { color: red; } - #qr .error:not([href]) { - cursor: default; - } td.replyhider { vertical-align: top; } @@ -2671,47 +2694,6 @@ main = width: 100%; } - #qr { - position: fixed; - max-height: 100%; - overflow-x: hidden; - overflow-y: auto; - } - #qr > div.move { - text-align: right; - } - #qr input[name=name] { - float: left; - } - #qr_form { - clear: left; - } - #qr_form, #qr #com_submit, #qr input[name=upfile] { - margin: 0; - } - #qr textarea { - width: 100%; - height: 125px; - } - #qr .close, #qr #autohide { - float: right; - } - #qr:not(:hover) > #autohide:checked ~ form { - height: 0; - overflow: hidden; - } - /* http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css */ - #qr input::-webkit-input-placeholder { - color: grey; - } - #qr input:-moz-placeholder { - color: grey; - } - /* qr reCAPTCHA */ - #qr img { - border: 1px solid #AAA; - } - #updater { position: fixed; text-align: right; @@ -2776,6 +2758,32 @@ main = #files > input { display: block; } + #qr { + position: fixed; + } + #qr #autohide, #qr .close { + float: right; + } + #qr:not(:hover) #autohide:checked ~ .autohide { + height: 0; + overflow: hidden; + } + #qr textarea { + border: 0; + height: 125; + width: 100%; + } + #qr #captcha { + position: relative; + } + #qr #cl { + right: 0; + padding: 2px; + position: absolute; + } + #qr #recaptcha_response_field { + width: 100%; + } ' main.init() From 649ed38d0390f71a5f78259d170580a8c8c819d1 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 02:54:43 -0700 Subject: [PATCH 077/130] 1337 (55 --- 4chan_x.user.js | 11 ++++++++++- script.coffee | 30 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2ea3fdb0b..e1680e335 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1378,7 +1378,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
120 Captchas
Derp
", { + }, " X
Subject Name Email
120 Captchas
Derp
", { /* " X @@ -3454,6 +3454,15 @@ #qr #autohide, #qr .close {\ float: right;\ }\ + #qr .input input {\ + width: 60px;\ + }\ + #qr .input:not(:hover) input:not(:focus) {\ + display: none;\ + }\ + #qr .input:hover span, #qr .input input:focus + span {\ + display: none;\ + }\ #qr:not(:hover) #autohide:checked ~ .autohide {\ height: 0;\ overflow: hidden;\ diff --git a/script.coffee b/script.coffee index a14e8ce8a..862678e57 100644 --- a/script.coffee +++ b/script.coffee @@ -1072,9 +1072,9 @@ QR =
- Subject - Name - Email + Subject + Name + Email
@@ -1091,6 +1091,21 @@ QR =
" + + + + + + + + + + + + + + + ### " X @@ -2764,6 +2779,15 @@ main = #qr #autohide, #qr .close { float: right; } + #qr .input input { + width: 60px; + } + #qr .input:not(:hover) input:not(:focus) { + display: none; + } + #qr .input:hover span, #qr .input input:focus + span { + display: none; + } #qr:not(:hover) #autohide:checked ~ .autohide { height: 0; overflow: hidden; From 37804ee75c0990ecbc22d600788d1f78425b53c8 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 02:56:18 -0700 Subject: [PATCH 078/130] shuffle --- 4chan_x.user.js | 73 ++++++++++++++++++++++++------------------------- script.coffee | 62 ++++++++++++++++------------------------- 2 files changed, 59 insertions(+), 76 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e1680e335..7ec431839 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1375,46 +1375,45 @@ if (text == null) { text = ''; } + /* + " + X +
Quick Reply
+ + + + + +
#{QR.spoiler}
+
+
+
+
+
#{QR.file}
+ +
+ + + " + #XXX use dom methods to set values instead of injecting raw user input into your html -_-; + c = d.cookie + $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + $('textarea', qr).value = text + QR.captchaLength() + QR.cooldown() if conf['Cooldown'] + $.bind $('.close', qr), 'click', QR.close + $.bind $('form', qr), 'submit', QR.submit + $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown + $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener + $.bind $('[type=file]', qr), 'change', QR.change + $.bind $('#attach', qr), 'click', QR.attach + */ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
", { - /* - " - X -
Quick Reply
-
- - - - -
#{QR.spoiler}
-
-
-
-
-
#{QR.file}
-
-
- - - " - #XXX use dom methods to set values instead of injecting raw user input into your html -_-; - c = d.cookie - $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $('textarea', qr).value = text - QR.captchaLength() - QR.cooldown() if conf['Cooldown'] - $.bind $('.close', qr), 'click', QR.close - $.bind $('form', qr), 'submit', QR.submit - $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown - $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener - $.bind $('[type=file]', qr), 'change', QR.change - $.bind $('#attach', qr), 'click', QR.attach - */ - }); + }, " X
Subject Name Email
120 Captchas
Derp
"); QR.captchaImg(); $.append(d.body, qr); ta = $('textarea', qr); diff --git a/script.coffee b/script.coffee index 862678e57..7d98c4da8 100644 --- a/script.coffee +++ b/script.coffee @@ -1067,45 +1067,6 @@ QR = disabled: false QR.submit() if $('#auto', QR.qr).checked dialog: (text='', tid) -> - QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " - X - -
- - Subject - Name - Email -
-
- -
-
- 120 Captchas - -
-
- - - Derp -
-
- " - - - - - - - - - - - - - - - - ### " X @@ -1141,6 +1102,29 @@ QR = $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach ### + QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " + X + +
+ + Subject + Name + Email +
+
+ +
+
+ 120 Captchas + +
+
+ + + Derp +
+
+ " QR.captchaImg() $.append d.body, qr ta = $ 'textarea', qr From 0312d61de7000c72f186f114f6eac01fca78d931 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 03:01:33 -0700 Subject: [PATCH 079/130] clickable --- 4chan_x.user.js | 5 ++++- script.coffee | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7ec431839..bb92e7289 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1413,7 +1413,10 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, " X
Subject Name Email
120 Captchas
Derp
"); + $.bind($('.click', qr), 'mousedown', function(e) { + return e.stopPropagation(); + }); QR.captchaImg(); $.append(d.body, qr); ta = $('textarea', qr); diff --git a/script.coffee b/script.coffee index 7d98c4da8..3623d5d52 100644 --- a/script.coffee +++ b/script.coffee @@ -1106,10 +1106,12 @@ QR = X
- - Subject - Name - Email + + + Subject + Name + Email +
@@ -1125,6 +1127,7 @@ QR =
" + $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() QR.captchaImg() $.append d.body, qr ta = $ 'textarea', qr From 8245ecba83a46485a5371f8f165b9e0687a7f1e2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 03:22:35 -0700 Subject: [PATCH 080/130] kind of actually works --- 4chan_x.user.js | 22 ++++++++++++++-------- script.coffee | 37 ++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bb92e7289..ca6896160 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1311,7 +1311,7 @@ $.set('captchas', captchas); el.value = ''; Recaptcha.reload(); - return captchaLength(captchas); + return QR.captchaLength(captchas); }, captchaShift: function() { var captcha, captchas, cutoff; @@ -1323,7 +1323,7 @@ } } $.set('captchas', captchas); - captchaLength(captchas); + QR.captchaLength(captchas); return captcha; }, captchaLength: function(captchas) { @@ -1375,6 +1375,9 @@ if (text == null) { text = ''; } + if (tid == null) { + tid = g.THREAD_ID; + } /* " X @@ -1401,23 +1404,23 @@ $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text - QR.captchaLength() QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close - $.bind $('form', qr), 'submit', QR.submit - $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown - $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach */ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, " X
Subject Name Email
120 Captchas
Derp
"); $.bind($('.click', qr), 'mousedown', function(e) { return e.stopPropagation(); }); + $.bind($('form', qr), 'submit', QR.submit); + $.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown); + $.bind($('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener); QR.captchaImg(); + QR.captchaLength(); $.append(d.body, qr); ta = $('textarea', qr); l = text.length; @@ -3465,7 +3468,10 @@ #qr .input:hover span, #qr .input input:focus + span {\ display: none;\ }\ - #qr:not(:hover) #autohide:checked ~ .autohide {\ + #qr form {\ + margin: 0;\ + }\ + #qr:not(:hover) #autohide:checked ~ form {\ height: 0;\ overflow: hidden;\ }\ diff --git a/script.coffee b/script.coffee index 3623d5d52..ab9fbacf6 100644 --- a/script.coffee +++ b/script.coffee @@ -1026,7 +1026,7 @@ QR = $.set 'captchas', captchas el.value = '' Recaptcha.reload() - captchaLength captchas + QR.captchaLength captchas captchaShift: -> captchas = $.get 'captchas', [] cutoff = Date.now() - 5*HOUR + 5*MINUTE @@ -1034,7 +1034,7 @@ QR = if captcha.time > cutoff break $.set 'captchas', captchas - captchaLength captchas + QR.captchaLength captchas captcha captchaLength: (captchas) -> captchas or= $.get 'captchas', [] @@ -1066,7 +1066,7 @@ QR = textContent: 'Submit' disabled: false QR.submit() if $('#auto', QR.qr).checked - dialog: (text='', tid) -> + dialog: (text='', tid=g.THREAD_ID) -> ### "
X @@ -1093,12 +1093,8 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text - QR.captchaLength() QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close - $.bind $('form', qr), 'submit', QR.submit - $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown - $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach ### @@ -1108,13 +1104,17 @@ QR =
- Subject - Name - Email + Subject + Name + Email
-
- +
+ + + + +
120 Captchas @@ -1123,12 +1123,16 @@ QR =
- Derp + Derp
-
+ " $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() + $.bind $('form', qr), 'submit', QR.submit + $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown + $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener QR.captchaImg() + QR.captchaLength() $.append d.body, qr ta = $ 'textarea', qr l = text.length @@ -2775,7 +2779,10 @@ main = #qr .input:hover span, #qr .input input:focus + span { display: none; } - #qr:not(:hover) #autohide:checked ~ .autohide { + #qr form { + margin: 0; + } + #qr:not(:hover) #autohide:checked ~ form { height: 0; overflow: hidden; } From cb10ce14c6665e20ab8f75a3522dc29bd843f9b4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 03:25:13 -0700 Subject: [PATCH 081/130] -g.THREAD_ID --- 4chan_x.user.js | 8 ++++---- script.coffee | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ca6896160..015ca05a8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -913,7 +913,7 @@ if (QR.qr) { return $('textarea', QR.qr).focus(); } else { - return QR.dialog('', g.THREAD_ID || thread.firstChild.id); + return QR.dialog('', thread != null ? thread.firstChild.id : void 0); } } }, @@ -1436,15 +1436,15 @@ return QR.submit(); }, quote: function(e, blank) { - var i, id, qr, s, sel, ss, ta, text, tid, v, _ref; + var i, id, qr, s, sel, ss, ta, text, tid, v, _ref, _ref2; if (e != null) { e.preventDefault(); } - tid = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', this).id; + tid = (_ref = $.x('ancestor::div[@class="thread"]/div', this)) != null ? _ref.id : void 0; id = this.textContent; text = ">>" + id + "\n"; sel = getSelection(); - if (id === ((_ref = $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)) != null ? _ref.name : void 0)) { + if (id === ((_ref2 = $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)) != null ? _ref2.name : void 0)) { if (s = sel.toString().replace(/\n/g, '\n>')) { text += ">" + s + "\n"; } diff --git a/script.coffee b/script.coffee index ab9fbacf6..455c8a3bd 100644 --- a/script.coffee +++ b/script.coffee @@ -656,7 +656,7 @@ keybinds = if QR.qr $('textarea', QR.qr).focus() else - QR.dialog '', g.THREAD_ID or thread.firstChild.id + QR.dialog '', thread?.firstChild.id open: (thread, tab) -> id = thread.firstChild.id @@ -1145,7 +1145,7 @@ QR = QR.submit() #derpy, but prevents checking for content twice quote: (e, blank) -> e?.preventDefault() - tid = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', @).id + tid = $.x('ancestor::div[@class="thread"]/div', @)?.id id = @textContent text = ">>#{id}\n" sel = getSelection() From 9e21a8f55d49d670356d1ac3252d1e77ed5208d6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 03:27:29 -0700 Subject: [PATCH 082/130] cooldown, close --- 4chan_x.user.js | 10 ++++++---- script.coffee | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 015ca05a8..0a2e51955 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1353,7 +1353,7 @@ cooldown = $.get("cooldown/" + g.BOARD, 0); now = Date.now(); n = Math.ceil((cooldown - now) / 1000); - b = $('button', QR.qr); + b = $('form button', QR.qr); if (n > 0) { $.extend(b, { textContent: n, @@ -1365,7 +1365,7 @@ textContent: 'Submit', disabled: false }); - if ($('#auto', QR.qr).checked) { + if ($('#autopost', QR.qr).checked) { return QR.submit(); } } @@ -1404,8 +1404,6 @@ $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text - QR.cooldown() if conf['Cooldown'] - $.bind $('.close', qr), 'click', QR.close $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach */ @@ -1413,6 +1411,10 @@ top: '0', left: '0' }, "
X
Subject Name Email
120 Captchas
Derp
"); + if (conf['Cooldown']) { + QR.cooldown(); + } + $.bind($('.close', qr), 'click', QR.close); $.bind($('.click', qr), 'mousedown', function(e) { return e.stopPropagation(); }); diff --git a/script.coffee b/script.coffee index 455c8a3bd..0e5862b80 100644 --- a/script.coffee +++ b/script.coffee @@ -1055,7 +1055,7 @@ QR = cooldown = $.get "cooldown/#{g.BOARD}", 0 now = Date.now() n = Math.ceil (cooldown - now) / 1000 - b = $ 'button', QR.qr + b = $ 'form button', QR.qr if n > 0 $.extend b, textContent: n @@ -1065,7 +1065,7 @@ QR = $.extend b, textContent: 'Submit' disabled: false - QR.submit() if $('#auto', QR.qr).checked + QR.submit() if $('#autopost', QR.qr).checked dialog: (text='', tid=g.THREAD_ID) -> ### " @@ -1093,8 +1093,6 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text - QR.cooldown() if conf['Cooldown'] - $.bind $('.close', qr), 'click', QR.close $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach ### @@ -1127,6 +1125,8 @@ QR =
" + QR.cooldown() if conf['Cooldown'] + $.bind $('.close', qr), 'click', QR.close $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() $.bind $('form', qr), 'submit', QR.submit $.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown From b2a5dd90873e14b8870d5d78a202a54201134b4c Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 03:33:00 -0700 Subject: [PATCH 083/130] name email text --- 4chan_x.user.js | 10 +++++----- script.coffee | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0a2e51955..7d84451ae 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1371,7 +1371,7 @@ } }, dialog: function(text, tid) { - var l, qr, ta; + var c, l, m, qr, ta; if (text == null) { text = ''; } @@ -1399,11 +1399,7 @@ " #XXX use dom methods to set values instead of injecting raw user input into your html -_-; - c = d.cookie - $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $('textarea', qr).value = text $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach */ @@ -1411,6 +1407,10 @@ top: '0', left: '0' }, " X
Subject Name Email
120 Captchas
Derp
"); + c = d.cookie; + $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('textarea', qr).value = text; if (conf['Cooldown']) { QR.cooldown(); } diff --git a/script.coffee b/script.coffee index 0e5862b80..8b417634b 100644 --- a/script.coffee +++ b/script.coffee @@ -1088,11 +1088,7 @@ QR =
" #XXX use dom methods to set values instead of injecting raw user input into your html -_-; - c = d.cookie - $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $('textarea', qr).value = text $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach ### @@ -1125,6 +1121,10 @@ QR = " + c = d.cookie + $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('textarea', qr).value = text QR.cooldown() if conf['Cooldown'] $.bind $('.close', qr), 'click', QR.close $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() From e4755e87715bb95394f817b75b86350241b0f8f4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 03:42:13 -0700 Subject: [PATCH 084/130] com placeholder --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7d84451ae..5bc87588f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1406,7 +1406,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, "
X
Subject Name Email
120 Captchas
Derp
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 8b417634b..9f8d47249 100644 --- a/script.coffee +++ b/script.coffee @@ -1108,7 +1108,7 @@ QR = - +
- - - - + + + + +
@@ -2773,9 +2774,12 @@ main = #qr .input input { width: 60px; } - #qr .input:not(:hover) input:not(:focus) { + #qr input { display: none; } + #qr .input:hover input, #qr input:focus { + display: inline; + } #qr .input:hover span, #qr .input input:focus + span { display: none; } @@ -2800,6 +2804,7 @@ main = position: absolute; } #qr #recaptcha_response_field { + display: inline; width: 100%; } ' From 5d8ca84b50e5149f0f4acd034a9413a6d857fdc2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 04:04:37 -0700 Subject: [PATCH 086/130] file --- 4chan_x.user.js | 5 ++++- script.coffee | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8f64b7179..ceb127c8f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1406,7 +1406,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, " X
Subject Name Email
120 Captchas
Derp
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -1414,6 +1414,9 @@ if (conf['Cooldown']) { QR.cooldown(); } + $.bind($('button', qr), 'click', function() { + return $('[type=file]', qr).click(); + }); $.bind($('.close', qr), 'click', QR.close); $.bind($('.click', qr), 'mousedown', function(e) { return e.stopPropagation(); diff --git a/script.coffee b/script.coffee index 331ff3dda..b6e68777e 100644 --- a/script.coffee +++ b/script.coffee @@ -1108,13 +1108,13 @@ QR = -
120 Captchas
+
@@ -1127,6 +1127,7 @@ QR = $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('textarea', qr).value = text QR.cooldown() if conf['Cooldown'] + $.bind $('button', qr), 'click', -> $('[type=file]', qr).click() $.bind $('.close', qr), 'click', QR.close $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() $.bind $('form', qr), 'submit', QR.submit From 7d48f0e5627cba2ef21bac78ebc2ed16530b47ae Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 04:14:02 -0700 Subject: [PATCH 087/130] thumbs --- 4chan_x.user.js | 18 +++++++++++++++--- script.coffee | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ceb127c8f..487308238 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1331,11 +1331,23 @@ return $('#cl', QR.qr).textContent = captchas.length + ' captchas'; }, change: function(e) { - if (this.files[0].size > QR.MAX_FILE_SIZE) { + var file, fr; + file = this.files[0]; + if (file.size > QR.MAX_FILE_SIZE) { alert('Error: File too large.'); QR.resetFile(this); return $('[type=file]', QR.qr).click(); } else { + fr = new FileReader(); + fr.onload = function(e) { + var img; + img = $.el('img', { + src: e.target.result + }); + return $.append($('#thumbs', QR.qr), img); + }; + fr.readAsDataURL(file); + return; if (this === $('#files div:last-of-type input', QR.qr)) { return QR.attach(); } @@ -1400,13 +1412,12 @@ " #XXX use dom methods to set values instead of injecting raw user input into your html -_-; $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach */ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, "
X
Subject Name Email
120 Captchas
Derp
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -1417,6 +1428,7 @@ $.bind($('button', qr), 'click', function() { return $('[type=file]', qr).click(); }); + $.bind($('[type=file]', qr), 'change', QR.change); $.bind($('.close', qr), 'click', QR.close); $.bind($('.click', qr), 'mousedown', function(e) { return e.stopPropagation(); diff --git a/script.coffee b/script.coffee index b6e68777e..b7f3adc0f 100644 --- a/script.coffee +++ b/script.coffee @@ -1040,11 +1040,19 @@ QR = captchas or= $.get 'captchas', [] $('#cl', QR.qr).textContent = captchas.length + ' captchas' change: (e) -> - if @files[0].size > QR.MAX_FILE_SIZE + file = @files[0] + if file.size > QR.MAX_FILE_SIZE alert 'Error: File too large.' QR.resetFile @ $('[type=file]', QR.qr).click() else + fr = new FileReader() + fr.onload = (e) -> + img = $.el 'img', + src: e.target.result + $.append $('#thumbs', QR.qr), img + fr.readAsDataURL file + return if @ is $('#files div:last-of-type input', QR.qr) QR.attach() close: -> @@ -1089,7 +1097,6 @@ QR = " #XXX use dom methods to set values instead of injecting raw user input into your html -_-; $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $.bind $('[type=file]', qr), 'change', QR.change $.bind $('#attach', qr), 'click', QR.attach ### QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " @@ -1108,13 +1115,14 @@ QR = +
120 Captchas
- +
@@ -1128,6 +1136,7 @@ QR = $('textarea', qr).value = text QR.cooldown() if conf['Cooldown'] $.bind $('button', qr), 'click', -> $('[type=file]', qr).click() + $.bind $('[type=file]', qr), 'change', QR.change $.bind $('.close', qr), 'click', QR.close $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() $.bind $('form', qr), 'submit', QR.submit From 5e48cc98da4b95deb6886e080d9c77765f50e971 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 04:17:55 -0700 Subject: [PATCH 088/130] overflow-y --- 4chan_x.user.js | 2 ++ script.coffee | 2 ++ 2 files changed, 4 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 487308238..6b20af99b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3471,6 +3471,8 @@ display: block;\ }\ #qr {\ + max-height: 100%;\ + overflow-y: auto;\ position: fixed;\ }\ #qr #autohide, #qr .close {\ diff --git a/script.coffee b/script.coffee index b7f3adc0f..50644e924 100644 --- a/script.coffee +++ b/script.coffee @@ -2776,6 +2776,8 @@ main = display: block; } #qr { + max-height: 100%; + overflow-y: auto; position: fixed; } #qr #autohide, #qr .close { From c10029bc3756143ddb2f9f01f76a08161f9dce48 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 23:23:50 -0700 Subject: [PATCH 089/130] append -> add --- 4chan_x.user.js | 8 ++++---- script.coffee | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fb61d5c4b..8e546d42a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1227,7 +1227,7 @@ quote = $('a.quotejs + a', root); return $.bind(quote, 'click', QR.quote); }); - $.append(d.body, $.el('iframe', { + $.add(d.body, $.el('iframe', { name: 'iframe', hidden: true })); @@ -1270,7 +1270,7 @@ $.bind($('a', div), 'click', function() { return $.rm(this.parentNode); }); - $.append($('#files', QR.qr), div); + $.add($('#files', QR.qr), div); return file.click(); }, attachNext: function() { @@ -1341,7 +1341,7 @@ img = $.el('img', { src: e.target.result }); - return $.append($('#thumbs', QR.qr), img); + return $.add($('#thumbs', QR.qr), img); }; fr.readAsDataURL(file); return; @@ -1435,7 +1435,7 @@ $.bind($('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener); QR.captchaImg(); QR.captchaLength(); - $.append(d.body, qr); + $.add(d.body, qr); ta = $('textarea', qr); l = text.length; ta.setSelectionRange(l, l); diff --git a/script.coffee b/script.coffee index 3473b3329..dcd36dc6e 100644 --- a/script.coffee +++ b/script.coffee @@ -963,7 +963,7 @@ QR = g.callbacks.push (root) -> quote = $ 'a.quotejs + a', root $.bind quote, 'click', QR.quote - $.append d.body, $.el 'iframe', + $.add d.body, $.el 'iframe', name: 'iframe' hidden: true $.bind window, 'message', QR.receive @@ -995,7 +995,7 @@ QR = file = $ 'input', div $.bind file, 'change', QR.change $.bind $('a', div), 'click', -> $.rm @parentNode - $.append $('#files', QR.qr), div + $.add $('#files', QR.qr), div file.click() attachNext: -> old = $ '[type=file]', QR.qr @@ -1046,7 +1046,7 @@ QR = fr.onload = (e) -> img = $.el 'img', src: e.target.result - $.append $('#thumbs', QR.qr), img + $.add $('#thumbs', QR.qr), img fr.readAsDataURL file return if @ is $('#files div:last-of-type input', QR.qr) @@ -1140,7 +1140,7 @@ QR = $.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener QR.captchaImg() QR.captchaLength() - $.append d.body, qr + $.add d.body, qr ta = $ 'textarea', qr l = text.length ta.setSelectionRange l, l From 58c51a2671ae548aaaeecb8c93717dce8f26c32c Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 10:19:11 -0700 Subject: [PATCH 090/130] hidden div, css tweaks --- 4chan_x.user.js | 10 ++++------ script.coffee | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8e546d42a..4b1c84c81 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1414,7 +1414,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, "
X
Subject Name Email
120 Captchas
Derp
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -3476,16 +3476,14 @@ #qr #autohide, #qr .close {\ float: right;\ }\ - #qr .input input {\ + #qr .click input {\ width: 60px;\ - }\ - #qr input {\ display: none;\ }\ - #qr .input:hover input, #qr input:focus {\ + #qr .click span:hover input, #qr .click input:focus {\ display: inline;\ }\ - #qr .input:hover span, #qr .input input:focus + span {\ + #qr .click span:hover span, #qr .click input:focus + span {\ display: none;\ }\ #qr form {\ diff --git a/script.coffee b/script.coffee index dcd36dc6e..64379f5e2 100644 --- a/script.coffee +++ b/script.coffee @@ -1101,17 +1101,19 @@ QR =
- Subject - Name - Email + Subject + Name + Email
- - - - - +
@@ -2778,16 +2780,14 @@ main = #qr #autohide, #qr .close { float: right; } - #qr .input input { + #qr .click input { width: 60px; - } - #qr input { display: none; } - #qr .input:hover input, #qr input:focus { + #qr .click span:hover input, #qr .click input:focus { display: inline; } - #qr .input:hover span, #qr .input input:focus + span { + #qr .click span:hover span, #qr .click input:focus + span { display: none; } #qr form { From 60282fb0466b0da9b979988461d22cd06f76cfbd Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 10:30:17 -0700 Subject: [PATCH 091/130] thumb css --- 4chan_x.user.js | 5 +++++ script.coffee | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4b1c84c81..9cec3a752 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3510,6 +3510,11 @@ display: inline;\ width: 100%;\ }\ + #qr #thumbs img {\ + display: block;\ + max-height: 250px;\ + max-width: 250px;\ + }\ ' }; main.init(); diff --git a/script.coffee b/script.coffee index 64379f5e2..d29730ca8 100644 --- a/script.coffee +++ b/script.coffee @@ -2814,6 +2814,11 @@ main = display: inline; width: 100%; } + #qr #thumbs img { + display: block; + max-height: 250px; + max-width: 250px; + } ' main.init() From 4d3eeb028586805b45410af76036717ecdf1a4a3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 10:42:38 -0700 Subject: [PATCH 092/130] thumbs above captcha --- 4chan_x.user.js | 4 ++-- script.coffee | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9cec3a752..5282eedc4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1297,7 +1297,7 @@ return; } c = QR.captcha.challenge; - return $('img', qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; + return $('#captcha img', qr).src = "http://www.google.com/recaptcha/api/image?c=" + c; }, captchaPush: function(el) { var captcha, captchas; @@ -1414,7 +1414,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, " X
Subject Name Email
120 Captchas
Derp
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index d29730ca8..03e4b4063 100644 --- a/script.coffee +++ b/script.coffee @@ -1013,7 +1013,7 @@ QR = {qr} = QR return unless qr c = QR.captcha.challenge - $('img', qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" + $('#captcha img', qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" captchaPush: (el) -> {captcha} = QR captcha.response = el.value @@ -1115,12 +1115,12 @@ QR =
-
+
+
120 Captchas
-
From 10c1575c8835836bac481f249ed1b684ad09d782 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 11:54:15 -0700 Subject: [PATCH 093/130] spoiler --- 4chan_x.user.js | 2 +- script.coffee | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5282eedc4..9ef8bc759 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1414,7 +1414,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
Derp
"); + }, "
X
Subject Name Email
120 Captchas
" + QR.spoiler + "
Derp "); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 03e4b4063..298f8dccc 100644 --- a/script.coffee +++ b/script.coffee @@ -1123,9 +1123,10 @@ QR =
+ Derp " c = d.cookie From eeef347471f49463307c1464dde7f2fda504a3ab Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 11:58:18 -0700 Subject: [PATCH 094/130] pass, delete old qr html --- 4chan_x.user.js | 27 ++------------------------- script.coffee | 34 +++++++--------------------------- 2 files changed, 9 insertions(+), 52 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9ef8bc759..1161e910d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1387,37 +1387,14 @@ if (tid == null) { tid = g.THREAD_ID; } - /* - " - X -
Quick Reply
-
- - - - -
#{QR.spoiler}
-
-
-
-
-
#{QR.file}
-
-
- - - " - #XXX use dom methods to set values instead of injecting raw user input into your html -_-; - $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $.bind $('#attach', qr), 'click', QR.attach - */ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email
120 Captchas
" + QR.spoiler + "
Derp "); + }, "
X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; $('textarea', qr).value = text; if (conf['Cooldown']) { QR.cooldown(); diff --git a/script.coffee b/script.coffee index 298f8dccc..fc0dbd5f5 100644 --- a/script.coffee +++ b/script.coffee @@ -1071,39 +1071,16 @@ QR = disabled: false QR.submit() if $('#autopost', QR.qr).checked dialog: (text='', tid=g.THREAD_ID) -> - ### - " -
X -
Quick Reply
-
- - - - -
#{QR.spoiler}
-
-
-
-
-
#{QR.file}
-
-
- - - " - #XXX use dom methods to set values instead of injecting raw user input into your html -_-; - $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $.bind $('#attach', qr), 'click', QR.attach - ### QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " X
- Subject - Name - Email + Subject + Name + Email + Password
@@ -1129,9 +1106,12 @@ QR = Derp " + #$.bind $('#attach', qr), 'click', QR.attach + #XXX use dom methods to set values instead of injecting raw user input into your html -_-; c = d.cookie $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text QR.cooldown() if conf['Cooldown'] $.bind $('button', qr), 'click', -> $('[type=file]', qr).click() From b4bf4037c6ec40f52c56c3519d7b5cb197b63d0a Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 12:02:12 -0700 Subject: [PATCH 095/130] ta height: 150px --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1161e910d..562cfa5c2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3472,7 +3472,7 @@ }\ #qr textarea {\ border: 0;\ - height: 125;\ + height: 150px;\ width: 100%;\ }\ #qr #captcha {\ diff --git a/script.coffee b/script.coffee index fc0dbd5f5..a31788610 100644 --- a/script.coffee +++ b/script.coffee @@ -2780,7 +2780,7 @@ main = } #qr textarea { border: 0; - height: 125; + height: 150px; width: 100%; } #qr #captcha { From 86f08d491ab1a7692cb0c22acf46eec8866a9abb Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 13:03:55 -0700 Subject: [PATCH 096/130] add multiple files --- 4chan_x.user.js | 54 ++++++++++++++++++++++++++++--------------------- script.coffee | 42 ++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 562cfa5c2..3d59133b7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1248,7 +1248,7 @@ return 'image/' + type; } }); - QR.file = ""; + QR.file = "click here"; QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = $('.postarea label') ? ' ' : ''; if (conf['Persistent QR']) { @@ -1259,6 +1259,20 @@ } } }, + foo: function() { + var div, file, files; + files = $('#files', QR.qr); + div = $.el('div', { + innerHTML: QR.file + }); + file = $('input', div); + $.bind(file, 'change', QR.change); + $.bind($('img', div), 'click', function() { + return this.previousSibling.click(); + }); + $.add(files, div); + return file.click(); + }, attach: function() { var div, file; $('#auto', QR.qr).checked = true; @@ -1328,27 +1342,21 @@ return $('#cl', QR.qr).textContent = captchas.length + ' captchas'; }, change: function(e) { - var file, fr; + var file, fr, img, qr; file = this.files[0]; if (file.size > QR.MAX_FILE_SIZE) { alert('Error: File too large.'); - QR.resetFile(this); - return $('[type=file]', QR.qr).click(); - } else { - fr = new FileReader(); - fr.onload = function(e) { - var img; - img = $.el('img', { - src: e.target.result - }); - return $.add($('#thumbs', QR.qr), img); - }; - fr.readAsDataURL(file); + $.rm(this.parentNode); + QR.foo(); return; - if (this === $('#files div:last-of-type input', QR.qr)) { - return QR.attach(); - } } + qr = QR.qr; + fr = new FileReader(); + img = this.nextSibling; + fr.onload = function(e) { + return img.src = e.target.result; + }; + return fr.readAsDataURL(file); }, close: function() { $.rm(QR.qr); @@ -1390,7 +1398,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, "
X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); + }, "
X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -1399,10 +1407,7 @@ if (conf['Cooldown']) { QR.cooldown(); } - $.bind($('button', qr), 'click', function() { - return $('[type=file]', qr).click(); - }); - $.bind($('[type=file]', qr), 'change', QR.change); + $.bind($('button', qr), 'click', QR.foo); $.bind($('.close', qr), 'click', QR.close); $.bind($('.click', qr), 'mousedown', function(e) { return e.stopPropagation(); @@ -3487,7 +3492,10 @@ display: inline;\ width: 100%;\ }\ - #qr #thumbs img {\ + #qr #files input {\ + display: none;\ + }\ + #qr #files img {\ display: block;\ max-height: 250px;\ max-width: 250px;\ diff --git a/script.coffee b/script.coffee index a31788610..4419108cd 100644 --- a/script.coffee +++ b/script.coffee @@ -980,7 +980,7 @@ QR = 'application/' + type else 'image/' + type - QR.file = "" + QR.file = "click here" QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value QR.spoiler = if $('.postarea label') then ' ' else '' if conf['Persistent QR'] @@ -988,6 +988,15 @@ QR = $('textarea', QR.qr).blur() if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true + foo: -> + files = $ '#files', QR.qr + div = $.el 'div', + innerHTML: QR.file + file = $ 'input', div + $.bind file, 'change', QR.change + $.bind $('img', div), 'click', -> @previousSibling.click() + $.add files, div + file.click() attach: -> $('#auto', QR.qr).checked = true div = $.el 'div', @@ -1039,18 +1048,15 @@ QR = file = @files[0] if file.size > QR.MAX_FILE_SIZE alert 'Error: File too large.' - QR.resetFile @ - $('[type=file]', QR.qr).click() - else - fr = new FileReader() - fr.onload = (e) -> - img = $.el 'img', - src: e.target.result - $.add $('#thumbs', QR.qr), img - fr.readAsDataURL file + $.rm @parentNode + QR.foo() return - if @ is $('#files div:last-of-type input', QR.qr) - QR.attach() + {qr} = QR + fr = new FileReader() + img = @nextSibling + fr.onload = (e) -> + img.src = e.target.result + fr.readAsDataURL file close: -> $.rm QR.qr QR.qr = null @@ -1089,10 +1095,9 @@ QR = -
-
+
120 Captchas @@ -1114,8 +1119,8 @@ QR = $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text QR.cooldown() if conf['Cooldown'] - $.bind $('button', qr), 'click', -> $('[type=file]', qr).click() - $.bind $('[type=file]', qr), 'change', QR.change + $.bind $('button', qr), 'click', QR.foo + #$.bind $('[type=file]', qr), 'change', QR.change $.bind $('.close', qr), 'click', QR.close $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() $.bind $('form', qr), 'submit', QR.submit @@ -2795,7 +2800,10 @@ main = display: inline; width: 100%; } - #qr #thumbs img { + #qr #files input { + display: none; + } + #qr #files img { display: block; max-height: 250px; max-width: 250px; From 7458f23753a4b436fef266e664ca356f3af7384a Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 13:08:12 -0700 Subject: [PATCH 097/130] rm file buttan --- 4chan_x.user.js | 6 ++++-- script.coffee | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3d59133b7..13a565cf8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1248,7 +1248,7 @@ return 'image/' + type; } }); - QR.file = "click here"; + QR.file = "click here
X"; QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = $('.postarea label') ? ' ' : ''; if (conf['Persistent QR']) { @@ -1270,6 +1270,9 @@ $.bind($('img', div), 'click', function() { return this.previousSibling.click(); }); + $.bind($('.x', div), 'click', function() { + return $.rm(this.parentNode); + }); $.add(files, div); return file.click(); }, @@ -3496,7 +3499,6 @@ display: none;\ }\ #qr #files img {\ - display: block;\ max-height: 250px;\ max-width: 250px;\ }\ diff --git a/script.coffee b/script.coffee index 4419108cd..b4a845c9c 100644 --- a/script.coffee +++ b/script.coffee @@ -980,7 +980,7 @@ QR = 'application/' + type else 'image/' + type - QR.file = "click here" + QR.file = "click hereX" QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value QR.spoiler = if $('.postarea label') then ' ' else '' if conf['Persistent QR'] @@ -995,6 +995,7 @@ QR = file = $ 'input', div $.bind file, 'change', QR.change $.bind $('img', div), 'click', -> @previousSibling.click() + $.bind $('.x', div), 'click', -> $.rm @parentNode $.add files, div file.click() attach: -> @@ -2804,7 +2805,6 @@ main = display: none; } #qr #files img { - display: block; max-height: 250px; max-width: 250px; } From 0d562fbbe944481c02b738f90bab4bdc848e1de5 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 13:14:19 -0700 Subject: [PATCH 098/130] -QR.file, +QR.accept --- 4chan_x.user.js | 7 +++---- script.coffee | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 13a565cf8..7b5c8ad30 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1221,7 +1221,7 @@ }; QR = { init: function() { - var accept, holder; + var holder; g.callbacks.push(function(root) { var quote; quote = $('a.quotejs + a', root); @@ -1238,7 +1238,7 @@ QR.captchaNode({ target: holder.firstChild }); - accept = $('.rules').textContent.match(/: (.+) /)[1].replace(/\w+/g, function(type) { + QR.accept = $('.rules').textContent.match(/: (.+) /)[1].replace(/\w+/g, function(type) { switch (type) { case 'JPG': return 'image/JPEG'; @@ -1248,7 +1248,6 @@ return 'image/' + type; } }); - QR.file = "click hereX"; QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = $('.postarea label') ? ' ' : ''; if (conf['Persistent QR']) { @@ -1263,7 +1262,7 @@ var div, file, files; files = $('#files', QR.qr); div = $.el('div', { - innerHTML: QR.file + innerHTML: "click hereX" }); file = $('input', div); $.bind(file, 'change', QR.change); diff --git a/script.coffee b/script.coffee index b4a845c9c..8404e036e 100644 --- a/script.coffee +++ b/script.coffee @@ -972,7 +972,7 @@ QR = holder = $ '#recaptcha_challenge_field_holder' $.bind holder, 'DOMNodeInserted', QR.captchaNode QR.captchaNode target: holder.firstChild - accept = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) -> + QR.accept = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) -> switch type when 'JPG' 'image/JPEG' @@ -980,7 +980,6 @@ QR = 'application/' + type else 'image/' + type - QR.file = "click hereX" QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value QR.spoiler = if $('.postarea label') then ' ' else '' if conf['Persistent QR'] @@ -991,7 +990,7 @@ QR = foo: -> files = $ '#files', QR.qr div = $.el 'div', - innerHTML: QR.file + innerHTML: "click hereX" file = $ 'input', div $.bind file, 'change', QR.change $.bind $('img', div), 'click', -> @previousSibling.click() From 2b9262bac3cbb63f8143ff2b4c8751c5eccf32d6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 13:50:09 -0700 Subject: [PATCH 099/130] no captcha autocomplete --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7b5c8ad30..003481b92 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1400,7 +1400,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); + }, "
X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 8404e036e..21670966e 100644 --- a/script.coffee +++ b/script.coffee @@ -1101,7 +1101,7 @@ QR =
120 Captchas - +
From bc5e4d196c2057ecc08a845c19eaea9a4fcb7a54 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 13:57:54 -0700 Subject: [PATCH 100/130] input.form doesn't work, wtf --- 4chan_x.user.js | 59 ++++++++++++++----------------------------------- script.coffee | 42 ++++++++++------------------------- 2 files changed, 28 insertions(+), 73 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 003481b92..982378fd6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1258,8 +1258,9 @@ } } }, - foo: function() { + attach: function() { var div, file, files; + $('#autopost', QR.qr).checked = true; files = $('#files', QR.qr); div = $.el('div', { innerHTML: "click hereX" @@ -1275,30 +1276,6 @@ $.add(files, div); return file.click(); }, - attach: function() { - var div, file; - $('#auto', QR.qr).checked = true; - div = $.el('div', { - innerHTML: "" + QR.file + "X" - }); - file = $('input', div); - $.bind(file, 'change', QR.change); - $.bind($('a', div), 'click', function() { - return $.rm(this.parentNode); - }); - $.add($('#files', QR.qr), div); - return file.click(); - }, - attachNext: function() { - var file, old; - old = $('[type=file]', QR.qr); - if (file = $('#files input', QR.qr)) { - $.rm(file.parentNode); - return $.replace(old, file); - } else { - return QR.resetFile(old); - } - }, captchaNode: function(e) { QR.captcha = { challenge: e.target.value, @@ -1349,7 +1326,7 @@ if (file.size > QR.MAX_FILE_SIZE) { alert('Error: File too large.'); $.rm(this.parentNode); - QR.foo(); + QR.attach(); return; } qr = QR.qr; @@ -1400,7 +1377,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); + }, "
X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -1409,7 +1386,7 @@ if (conf['Cooldown']) { QR.cooldown(); } - $.bind($('button', qr), 'click', QR.foo); + $.bind($('button', qr), 'click', QR.attach); $.bind($('.close', qr), 'click', QR.close); $.bind($('.click', qr), 'mousedown', function(e) { return e.stopPropagation(); @@ -1462,22 +1439,25 @@ return ta.focus(); }, receive: function(e) { - var data, tc, _ref; + var data, qr, row, tc, _ref, _ref2; $('iframe[name=iframe]').src = 'about:blank'; + qr = QR.qr; + row = (_ref = $('#files input[form]', qr)) != null ? _ref.parentNode : void 0; data = e.data; if (data) { data = JSON.parse(data); $.extend($('a.error', QR.qr), data); tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { - QR.attachNext(); + $.rm(row); setTimeout(QR.submit, 1000); } else if (tc === 'You seem to have mistyped the verification.') { setTimeout(QR.submit, 1000); } return; } - if (conf['Persistent QR'] || ((_ref = $('#files input', QR.qr)) != null ? _ref.files.length : void 0)) { + $.rm(row); + if (conf['Persistent QR'] || ((_ref2 = $('#files input', QR.qr)) != null ? _ref2.files.length : void 0)) { QR.reset(); } else { QR.close(); @@ -1495,20 +1475,10 @@ _ref.checked = false; } } - $('textarea', QR.qr).value = ''; - return QR.attachNext(); - }, - resetFile: function(old) { - var div, file; - div = $.el('div', { - innerHTML: QR.file - }); - file = div.firstChild; - $.bind(file, 'change', QR.change); - return $.replace(old, file); + return $('textarea', QR.qr).value = ''; }, submit: function(e) { - var captcha, challenge, el, id, op, qr, response; + var captcha, challenge, el, id, input, op, qr, response; if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) { if (e) { alert('Error: No text entered.'); @@ -1534,6 +1504,9 @@ if (conf['Auto Hide QR']) { $('#autohide', qr).checked = true; } + if (input = $('#files input', qr)) { + input.setAttribute('form', 'qr_form'); + } if (!e) { $('#qr_form', qr).submit(); } diff --git a/script.coffee b/script.coffee index 21670966e..72c5326ef 100644 --- a/script.coffee +++ b/script.coffee @@ -987,7 +987,8 @@ QR = $('textarea', QR.qr).blur() if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true - foo: -> + attach: -> + $('#autopost', QR.qr).checked = true files = $ '#files', QR.qr div = $.el 'div', innerHTML: "click here
X" @@ -997,22 +998,6 @@ QR = $.bind $('.x', div), 'click', -> $.rm @parentNode $.add files, div file.click() - attach: -> - $('#auto', QR.qr).checked = true - div = $.el 'div', - innerHTML: "#{QR.file}X" - file = $ 'input', div - $.bind file, 'change', QR.change - $.bind $('a', div), 'click', -> $.rm @parentNode - $.add $('#files', QR.qr), div - file.click() - attachNext: -> - old = $ '[type=file]', QR.qr - if file = $ '#files input', QR.qr - $.rm file.parentNode - $.replace old, file - else - QR.resetFile old captchaNode: (e) -> QR.captcha = challenge: e.target.value @@ -1049,7 +1034,7 @@ QR = if file.size > QR.MAX_FILE_SIZE alert 'Error: File too large.' $.rm @parentNode - QR.foo() + QR.attach() return {qr} = QR fr = new FileReader() @@ -1089,6 +1074,8 @@ QR = Password
+ +
- -
120 Captchas @@ -1119,8 +1104,7 @@ QR = $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value $('textarea', qr).value = text QR.cooldown() if conf['Cooldown'] - $.bind $('button', qr), 'click', QR.foo - #$.bind $('[type=file]', qr), 'change', QR.change + $.bind $('button', qr), 'click', QR.attach $.bind $('.close', qr), 'click', QR.close $.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation() $.bind $('form', qr), 'submit', QR.submit @@ -1161,17 +1145,20 @@ QR = ta.focus() receive: (e) -> $('iframe[name=iframe]').src = 'about:blank' + {qr} = QR + row = $('#files input[form]', qr)?.parentNode {data} = e if data data = JSON.parse data $.extend $('a.error', QR.qr), data tc = data.textContent if tc is 'Error: Duplicate file entry detected.' - QR.attachNext() + $.rm row setTimeout QR.submit, 1000 else if tc is 'You seem to have mistyped the verification.' setTimeout QR.submit, 1000 return + $.rm row if conf['Persistent QR'] or $('#files input', QR.qr)?.files.length QR.reset() else @@ -1183,13 +1170,6 @@ QR = reset: -> $('[name=spoiler]', QR.qr)?.checked = false unless conf['Remember Spoiler'] $('textarea', QR.qr).value = '' - QR.attachNext() - resetFile: (old) -> - div = $.el 'div' - innerHTML: QR.file - file = div.firstChild - $.bind file, 'change', QR.change - $.replace old, file submit: (e) -> #XXX e is undefined if method is called explicitly, eg, from auto posting unless $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length @@ -1209,6 +1189,8 @@ QR = $('#challenge', qr).value = challenge $('#response', qr).value = response $('#autohide', qr).checked = true if conf['Auto Hide QR'] + if input = $ '#files input', qr + input.setAttribute 'form', 'qr_form' $('#qr_form', qr).submit() if not e QR.sage = /sage/i.test $('[name=email]', qr).value if conf['Thread Watcher'] and conf['Auto Watch Reply'] From 242ec22e89ccb598b4cf08e542ae9a49b8db70de Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 15:55:04 -0700 Subject: [PATCH 101/130] unsexy --- 4chan_x.user.js | 11 ++--------- script.coffee | 17 +++++------------ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8230a1b2a..ff3e7f8ce 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1424,7 +1424,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
Subject Name Email Password
120 Captchas
" + QR.spoiler + "
Derp "); + }, " X
120 Captchas
" + QR.spoiler + "
Derp "); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -3481,14 +3481,7 @@ float: right;\ }\ #qr .click input {\ - width: 60px;\ - display: none;\ - }\ - #qr .click span:hover input, #qr .click input:focus {\ - display: inline;\ - }\ - #qr .click span:hover span, #qr .click input:focus + span {\ - display: none;\ + width: 53px;\ }\ #qr form {\ margin: 0;\ diff --git a/script.coffee b/script.coffee index b0551be8b..712d5f190 100644 --- a/script.coffee +++ b/script.coffee @@ -1075,10 +1075,10 @@ QR =
- Subject - Name - Email - Password + + + +
@@ -2756,14 +2756,7 @@ main = float: right; } #qr .click input { - width: 60px; - display: none; - } - #qr .click span:hover input, #qr .click input:focus { - display: inline; - } - #qr .click span:hover span, #qr .click input:focus + span { - display: none; + width: 53px; } #qr form { margin: 0; From 97c96086193986c8b85a4c1bb880a457959ff130 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 16:28:52 -0700 Subject: [PATCH 102/130] guard --- 4chan_x.user.js | 4 ++-- script.coffee | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7169fffe4..bf3323e52 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1524,8 +1524,8 @@ return $('textarea', QR.qr).value = ''; }, submit: function(e) { - var captcha, challenge, el, id, input, op, qr, response; - if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) { + var captcha, challenge, el, id, input, op, qr, response, _ref; + if (!($('textarea', QR.qr).value || ((_ref = $('[type=file]', QR.qr)) != null ? _ref.files.length : void 0))) { if (e) { alert('Error: No text entered.'); e.preventDefault(); diff --git a/script.coffee b/script.coffee index 77f7be3ae..6e1d73cb1 100644 --- a/script.coffee +++ b/script.coffee @@ -1177,7 +1177,7 @@ QR = $('textarea', QR.qr).value = '' submit: (e) -> #XXX e is undefined if method is called explicitly, eg, from auto posting - unless $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length + unless $('textarea', QR.qr).value or $('[type=file]', QR.qr)?.files.length if e alert 'Error: No text entered.' e.preventDefault() From 967c919a98606da038a2657ca454e2deab688a0d Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 17:05:57 -0700 Subject: [PATCH 103/130] css tweak --- 4chan_x.user.js | 5 ++++- script.coffee | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bf3323e52..1ab4b8c73 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3480,7 +3480,10 @@ float: right;\ }\ #qr .click input {\ - width: 53px;\ + width: 57px;\ + }\ + #qr .click * {\ + float: left;\ }\ #qr form {\ margin: 0;\ diff --git a/script.coffee b/script.coffee index 6e1d73cb1..130ccfbb8 100644 --- a/script.coffee +++ b/script.coffee @@ -2754,7 +2754,10 @@ main = float: right; } #qr .click input { - width: 53px; + width: 57px; + } + #qr .click * { + float: left; } #qr form { margin: 0; From 28ec9674075b06d1b31ef24259583a5777727fe8 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 17:21:01 -0700 Subject: [PATCH 104/130] check if submit is disabled if all buttons are disabled, hitting enter in an input field won't submit the form, but calling form.submit() will still submit --- 4chan_x.user.js | 2 +- script.coffee | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1ab4b8c73..a727c4712 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1553,7 +1553,7 @@ if (input = $('#files input', qr)) { input.setAttribute('form', 'qr_form'); } - if (!e) { + if (!(e || $('form button', qr).disabled)) { $('#qr_form', qr).submit(); } QR.sage = /sage/i.test($('[name=email]', qr).value); diff --git a/script.coffee b/script.coffee index 130ccfbb8..9ad931f59 100644 --- a/script.coffee +++ b/script.coffee @@ -1196,7 +1196,8 @@ QR = $('#autohide', qr).checked = true if conf['Auto Hide QR'] if input = $ '#files input', qr input.setAttribute 'form', 'qr_form' - $('#qr_form', qr).submit() if not e + if not (e or $('form button', qr).disabled) + $('#qr_form', qr).submit() QR.sage = /sage/i.test $('[name=email]', qr).value if conf['Thread Watcher'] and conf['Auto Watch Reply'] id = $('input[name=resto]', qr.el).value From f393ba82a570c0b0e4989cec6561a907ab3148f2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 17:25:14 -0700 Subject: [PATCH 105/130] rm row if row --- 4chan_x.user.js | 8 ++++++-- script.coffee | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a727c4712..e8016fb14 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1495,14 +1495,18 @@ $.extend($('a.error', QR.qr), data); tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { - $.rm(row); + if (row) { + $.rm(row); + } setTimeout(QR.submit, 1000); } else if (tc === 'You seem to have mistyped the verification.') { setTimeout(QR.submit, 1000); } return; } - $.rm(row); + if (row) { + $.rm(row); + } if (conf['Persistent QR'] || ((_ref2 = $('#files input', QR.qr)) != null ? _ref2.files.length : void 0)) { QR.reset(); } else { diff --git a/script.coffee b/script.coffee index 9ad931f59..8f82d4ca2 100644 --- a/script.coffee +++ b/script.coffee @@ -1158,12 +1158,12 @@ QR = $.extend $('a.error', QR.qr), data tc = data.textContent if tc is 'Error: Duplicate file entry detected.' - $.rm row + $.rm row if row setTimeout QR.submit, 1000 else if tc is 'You seem to have mistyped the verification.' setTimeout QR.submit, 1000 return - $.rm row + $.rm row if row if conf['Persistent QR'] or $('#files input', QR.qr)?.files.length QR.reset() else From 6a41ade0d9ed6e9cd7fb80ee098a01d328e4f600 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 18:00:58 -0700 Subject: [PATCH 106/130] rm derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e8016fb14..77985dc8c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1423,7 +1423,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, "
X
120 Captchas
" + QR.spoiler + "
Derp "); + }, "
X
120 Captchas
" + QR.spoiler + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 8f82d4ca2..d9645b4da 100644 --- a/script.coffee +++ b/script.coffee @@ -1098,7 +1098,7 @@ QR = #{QR.spoiler}
- Derp + " #$.bind $('#attach', qr), 'click', QR.attach From 934cc321ff5e723ede700b098fd16dee6202e3f2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 18:10:57 -0700 Subject: [PATCH 107/130] return asap --- 4chan_x.user.js | 5 ++++- script.coffee | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 77985dc8c..a58b99d39 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1529,6 +1529,9 @@ }, submit: function(e) { var captcha, challenge, el, id, input, op, qr, response, _ref; + if ($('form button', qr).disabled) { + return; + } if (!($('textarea', QR.qr).value || ((_ref = $('[type=file]', QR.qr)) != null ? _ref.files.length : void 0))) { if (e) { alert('Error: No text entered.'); @@ -1557,7 +1560,7 @@ if (input = $('#files input', qr)) { input.setAttribute('form', 'qr_form'); } - if (!(e || $('form button', qr).disabled)) { + if (!e) { $('#qr_form', qr).submit(); } QR.sage = /sage/i.test($('[name=email]', qr).value); diff --git a/script.coffee b/script.coffee index d9645b4da..4e05d276a 100644 --- a/script.coffee +++ b/script.coffee @@ -1176,6 +1176,7 @@ QR = $('[name=spoiler]', QR.qr)?.checked = false unless conf['Remember Spoiler'] $('textarea', QR.qr).value = '' submit: (e) -> + return if $('form button', qr).disabled #XXX e is undefined if method is called explicitly, eg, from auto posting unless $('textarea', QR.qr).value or $('[type=file]', QR.qr)?.files.length if e @@ -1196,8 +1197,7 @@ QR = $('#autohide', qr).checked = true if conf['Auto Hide QR'] if input = $ '#files input', qr input.setAttribute 'form', 'qr_form' - if not (e or $('form button', qr).disabled) - $('#qr_form', qr).submit() + $('#qr_form', qr).submit() if not e QR.sage = /sage/i.test $('[name=email]', qr).value if conf['Thread Watcher'] and conf['Auto Watch Reply'] id = $('input[name=resto]', qr.el).value From 5abf8531dfaac18bf888662bb95ad85e104e26b9 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 19:02:43 -0700 Subject: [PATCH 108/130] create threads --- 4chan_x.user.js | 16 +++++++++------- script.coffee | 13 +++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a58b99d39..534835a5c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1389,7 +1389,7 @@ }, cooldown: function() { var b, n, now; - if (!QR.qr) { + if (!(g.REPLY && QR.qr)) { return; } cooldown = $.get("cooldown/" + g.BOARD, 0); @@ -1417,13 +1417,11 @@ if (text == null) { text = ''; } - if (tid == null) { - tid = g.THREAD_ID; - } + tid || (tid = g.THREAD_ID || ''); QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
120 Captchas
" + QR.spoiler + "
"); + }, "
X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -1457,7 +1455,7 @@ return QR.submit(); }, quote: function(e, blank) { - var i, id, qr, s, sel, ss, ta, text, tid, v, _ref, _ref2; + var i, id, qr, s, sel, ss, ta, text, tid, v, _base, _ref, _ref2; if (e != null) { e.preventDefault(); } @@ -1482,7 +1480,8 @@ ta.value = v.slice(0, ss) + text + v.slice(ss); i = ss + text.length; ta.setSelectionRange(i, i); - return ta.focus(); + ta.focus(); + return (_base = $('[name=resto]', qr)).value || (_base.value = tid); }, receive: function(e) { var data, qr, row, tc, _ref, _ref2; @@ -3523,6 +3522,9 @@ max-height: 250px;\ max-width: 250px;\ }\ + #qr input[name=resto] {\ + width: 80px;\ + }\ ' }; main.init(); diff --git a/script.coffee b/script.coffee index 4e05d276a..41387feee 100644 --- a/script.coffee +++ b/script.coffee @@ -1051,7 +1051,7 @@ QR = $.rm QR.qr QR.qr = null cooldown: -> - return unless QR.qr + return unless g.REPLY and QR.qr cooldown = $.get "cooldown/#{g.BOARD}", 0 now = Date.now() n = Math.ceil (cooldown - now) / 1000 @@ -1066,7 +1066,8 @@ QR = textContent: 'Submit' disabled: false QR.submit() if $('#autopost', QR.qr).checked - dialog: (text='', tid=g.THREAD_ID) -> + dialog: (text='', tid) -> + tid or= g.THREAD_ID or '' QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', "
X @@ -1083,7 +1084,6 @@ QR =
- + #{if g.REPLY then "" else ''} + #{QR.spoiler}
@@ -1148,6 +1149,7 @@ QR = i = ss + text.length ta.setSelectionRange i, i ta.focus() + $('[name=resto]', qr).value or= tid receive: (e) -> $('iframe[name=iframe]').src = 'about:blank' {qr} = QR @@ -2791,6 +2793,9 @@ main = max-height: 250px; max-width: 250px; } + #qr input[name=resto] { + width: 80px; + } ' main.init() From 4e37bd796136f567900642f3ec340a6f33396c3e Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 20:29:15 -0700 Subject: [PATCH 109/130] noko --- 4chan_x.user.js | 19 ++++++++++++++++--- script.coffee | 14 +++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 534835a5c..5d21e061f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1306,7 +1306,6 @@ }, attach: function() { var div, file, files; - $('#autopost', QR.qr).checked = true; files = $('#files', QR.qr); div = $.el('div', { innerHTML: "click hereX" @@ -1490,6 +1489,10 @@ row = (_ref = $('#files input[form]', qr)) != null ? _ref.parentNode : void 0; data = e.data; if (data) { + if (QR.op) { + window.location = data; + } + return; data = JSON.parse(data); $.extend($('a.error', QR.qr), data); tc = data.textContent; @@ -1563,8 +1566,12 @@ $('#qr_form', qr).submit(); } QR.sage = /sage/i.test($('[name=email]', qr).value); + id = $('input[name=resto]', qr).value; + QR.op = !id; + if (QR.op) { + $('[name=email]', qr).value = 'noko'; + } if (conf['Thread Watcher'] && conf['Auto Watch Reply']) { - id = $('input[name=resto]', qr.el).value; op = $.id(id); if ($('img.favicon', op).src === Favicon.empty) { return watcher.watch(op, id); @@ -1579,12 +1586,18 @@ } return $.globalEval(function() { var data, href, node, textContent, _ref; - if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) { + $ = function(css) { + return document.querySelector(css); + }; + if (node = (_ref = $('table font b')) != null ? _ref.firstChild : void 0) { textContent = node.textContent, href = node.href; + alert(textContent); data = JSON.stringify({ textContent: textContent, href: href }); + } else if (node = $('meta')) { + data = node.content.match(/url=(.+)/)[1]; } return parent.postMessage(data, '*'); }); diff --git a/script.coffee b/script.coffee index 41387feee..e93a81441 100644 --- a/script.coffee +++ b/script.coffee @@ -993,7 +993,7 @@ QR = if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true attach: -> - $('#autopost', QR.qr).checked = true + #$('#autopost', QR.qr).checked = true files = $ '#files', QR.qr div = $.el 'div', innerHTML: "click hereX" @@ -1156,6 +1156,8 @@ QR = row = $('#files input[form]', qr)?.parentNode {data} = e if data + window.location = data if QR.op + return data = JSON.parse data $.extend $('a.error', QR.qr), data tc = data.textContent @@ -1201,8 +1203,10 @@ QR = input.setAttribute 'form', 'qr_form' $('#qr_form', qr).submit() if not e QR.sage = /sage/i.test $('[name=email]', qr).value + id = $('input[name=resto]', qr).value + QR.op = not id + $('[name=email]', qr).value = 'noko' if QR.op if conf['Thread Watcher'] and conf['Auto Watch Reply'] - id = $('input[name=resto]', qr.el).value op = $.id id if $('img.favicon', op).src is Favicon.empty watcher.watch op, id @@ -1211,9 +1215,13 @@ QR = $.bind recaptcha, 'keydown', Recaptcha.listener return $.globalEval -> - if node = document.querySelector('table font b')?.firstChild + $ = (css) -> document.querySelector css + if node = $('table font b')?.firstChild {textContent, href} = node + alert textContent data = JSON.stringify {textContent, href} + else if node = $ 'meta' + data = node.content.match(/url=(.+)/)[1] parent.postMessage data, '*' #parent will blank us on message receival; #if we're not an iframe, we won't get blanked From 879b13477f89239b6b4a633348e6e6eb4c49384a Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 20:41:55 -0700 Subject: [PATCH 110/130] hidden password, img x styling --- 4chan_x.user.js | 10 ++++++++-- script.coffee | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5d21e061f..1b999f6fd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1420,7 +1420,7 @@ QR.qr = qr = ui.dialog('qr', { top: '0', left: '0' - }, " X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); + }, " X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -3499,7 +3499,7 @@ float: right;\ }\ #qr .click input {\ - width: 57px;\ + width: 73px;\ }\ #qr .click * {\ float: left;\ @@ -3519,6 +3519,12 @@ #qr #captcha {\ position: relative;\ }\ + #qr #files a {\ + position: absolute;\ + left: 0;\ + font-size: 50px;\ + color: red;\ + }\ #qr #cl {\ right: 0;\ padding: 2px;\ diff --git a/script.coffee b/script.coffee index e93a81441..24b40f79b 100644 --- a/script.coffee +++ b/script.coffee @@ -1077,13 +1077,13 @@ QR = -
- + " #$.bind $('#attach', qr), 'click', QR.attach From 0c99311b8d21fe018da5994bf89ce409967f330f Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 7 Sep 2011 14:52:33 -0700 Subject: [PATCH 115/130] 150x150 --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index de8f55892..1c48475f0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3151,8 +3151,8 @@ display: none;\ }\ #qr #files img {\ - max-height: 250px;\ - max-width: 250px;\ + max-height: 150px;\ + max-width: 150px;\ }\ #qr input[name=resto] {\ width: 80px;\ diff --git a/script.coffee b/script.coffee index e0956da82..0ac5948f5 100644 --- a/script.coffee +++ b/script.coffee @@ -2468,8 +2468,8 @@ main = display: none; } #qr #files img { - max-height: 250px; - max-width: 250px; + max-height: 150px; + max-width: 150px; } #qr input[name=resto] { width: 80px; From 22f5597e6f771abbbf74f07d27d06df53d5968cd Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 7 Sep 2011 17:18:54 -0700 Subject: [PATCH 116/130] horizontal scrolling --- 4chan_x.user.js | 20 ++++++++++++++------ script.coffee | 18 +++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1c48475f0..3a05394c7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1259,20 +1259,20 @@ } }, attach: function() { - var div, file, files; + var box, file, files; files = $('#files', QR.qr); - div = $.el('div', { + box = $.el('span', { innerHTML: "click hereX" }); - file = $('input', div); + file = $('input', box); $.bind(file, 'change', QR.change); - $.bind($('img', div), 'click', function() { + $.bind($('img', box), 'click', function() { return this.previousSibling.click(); }); - $.bind($('.x', div), 'click', function() { + $.bind($('.x', box), 'click', function() { return $.rm(this.parentNode); }); - $.add(files, div); + $.add(files, box); return file.click(); }, captchaNode: function(e) { @@ -3132,6 +3132,14 @@ #qr #captcha {\ position: relative;\ }\ + #qr #files {\ + width: 300px;\ + white-space: nowrap;\ + overflow: auto;\ + }\ + #qr #files span {\ + position: relative;\ + }\ #qr #files a {\ position: absolute;\ left: 0;\ diff --git a/script.coffee b/script.coffee index 0ac5948f5..5fa4186cc 100644 --- a/script.coffee +++ b/script.coffee @@ -969,13 +969,13 @@ QR = attach: -> #$('#autopost', QR.qr).checked = true files = $ '#files', QR.qr - div = $.el 'div', + box = $.el 'span', innerHTML: "click hereX" - file = $ 'input', div + file = $ 'input', box $.bind file, 'change', QR.change - $.bind $('img', div), 'click', -> @previousSibling.click() - $.bind $('.x', div), 'click', -> $.rm @parentNode - $.add files, div + $.bind $('img', box), 'click', -> @previousSibling.click() + $.bind $('.x', box), 'click', -> $.rm @parentNode + $.add files, box file.click() captchaNode: (e) -> QR.captcha = @@ -2449,6 +2449,14 @@ main = #qr #captcha { position: relative; } + #qr #files { + width: 300px; + white-space: nowrap; + overflow: auto; + } + #qr #files span { + position: relative; + } #qr #files a { position: absolute; left: 0; From 1d2c4a183dd29a3669425e39e7ebdfee216c8f03 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 12 Sep 2011 15:48:01 -0700 Subject: [PATCH 117/130] smaller thumbs --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3a05394c7..3750ca148 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3159,8 +3159,8 @@ display: none;\ }\ #qr #files img {\ - max-height: 150px;\ - max-width: 150px;\ + max-height: 100px;\ + max-width: 100px;\ }\ #qr input[name=resto] {\ width: 80px;\ diff --git a/script.coffee b/script.coffee index 5fa4186cc..8bb6e97eb 100644 --- a/script.coffee +++ b/script.coffee @@ -2476,8 +2476,8 @@ main = display: none; } #qr #files img { - max-height: 150px; - max-width: 150px; + max-height: 100px; + max-width: 100px; } #qr input[name=resto] { width: 80px; From 1524c27a8b15cb44cffce4161ded35a282821e79 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 20 Sep 2011 19:45:46 -0700 Subject: [PATCH 118/130] work w/ new ui.dialog format --- 4chan_x.user.js | 5 +---- script.coffee | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 30c9c3cc5..51d7e3497 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1363,10 +1363,7 @@ text = ''; } tid || (tid = g.THREAD_ID || ''); - QR.qr = qr = ui.dialog('qr', { - top: '0', - left: '0' - }, " X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); + QR.qr = qr = ui.dialog('qr', 'top: 0; left: 0;', " X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index 0cd0b6f91..cd042876d 100644 --- a/script.coffee +++ b/script.coffee @@ -1041,7 +1041,7 @@ QR = QR.submit() if $('#autopost', QR.qr).checked dialog: (text='', tid) -> tid or= g.THREAD_ID or '' - QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " + QR.qr = qr = ui.dialog 'qr', 'top: 0; left: 0;', " X
From 7a756dce2673ff9ef6889b4a7a3b42555369f14e Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 20 Sep 2011 19:50:55 -0700 Subject: [PATCH 119/130] autohide working --- 4chan_x.user.js | 4 ++-- script.coffee | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 51d7e3497..4618d278b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1363,7 +1363,7 @@ text = ''; } tid || (tid = g.THREAD_ID || ''); - QR.qr = qr = ui.dialog('qr', 'top: 0; left: 0;', " X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); + QR.qr = qr = ui.dialog('qr', 'top: 0; left: 0;', " X
120 Captchas
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); c = d.cookie; $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; @@ -3114,7 +3114,7 @@ #qr form {\ margin: 0;\ }\ - #qr:not(:hover) #autohide:checked ~ form {\ + #qr:not(:hover) #autohide:checked ~ .autohide {\ height: 0;\ overflow: hidden;\ }\ diff --git a/script.coffee b/script.coffee index cd042876d..b2f80e9e8 100644 --- a/script.coffee +++ b/script.coffee @@ -1052,28 +1052,30 @@ QR =
- -
-
- -
-
- 120 Captchas - -
-
- - #{if g.REPLY then "" else ''} - - #{QR.spoiler} -
- -
+
+ +
+
+ +
+
+ 120 Captchas + +
+
+ + #{if g.REPLY then "" else ''} + + #{QR.spoiler} +
+
+
+ " #$.bind $('#attach', qr), 'click', QR.attach #XXX use dom methods to set values instead of injecting raw user input into your html -_-; @@ -2448,7 +2450,7 @@ Main = #qr form { margin: 0; } - #qr:not(:hover) #autohide:checked ~ form { + #qr:not(:hover) #autohide:checked ~ .autohide { height: 0; overflow: hidden; } From 0396b52cedcafb05f4414b5438336873d672a8f7 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 20 Sep 2011 19:54:31 -0700 Subject: [PATCH 120/130] -Recaptcha, qr, +QR --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4618d278b..ecdd512cb 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1288,7 +1288,7 @@ captchas.push(captcha); $.set('captchas', captchas); el.value = ''; - Recaptcha.reload(); + QR.captchaReload(); return QR.captchaLength(captchas); }, captchaShift: function() { @@ -2934,7 +2934,7 @@ var data, origin; origin = e.origin, data = e.data; if (origin === 'http://sys.4chan.org') { - return qr.message(data); + return QR.message(data); } }, css: '\ diff --git a/script.coffee b/script.coffee index b2f80e9e8..7cec4ec7b 100644 --- a/script.coffee +++ b/script.coffee @@ -991,7 +991,7 @@ QR = captchas.push captcha $.set 'captchas', captchas el.value = '' - Recaptcha.reload() + QR.captchaReload() QR.captchaLength captchas captchaShift: -> captchas = $.get 'captchas', [] @@ -2271,7 +2271,7 @@ Main = message: (e) -> {origin, data} = e if origin is 'http://sys.4chan.org' - qr.message data + QR.message data css: ' /* dialog styling */ From 7dc976d8bf80da03b9060e5d0c6ce8957d0ac1e0 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 20 Sep 2011 23:14:49 -0700 Subject: [PATCH 121/130] rm comment --- script.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/script.coffee b/script.coffee index 7cec4ec7b..85deee382 100644 --- a/script.coffee +++ b/script.coffee @@ -927,7 +927,6 @@ options = $('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789' QR = - #TODO create new thread #captcha caching for report form #report queueing #check if captchas can be reused on eg dup file error From bd4fcef2f0453e7e9cd7abf0461fe5cdc768ba8c Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 20 Sep 2011 23:55:27 -0700 Subject: [PATCH 122/130] rm commented out line --- script.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/script.coffee b/script.coffee index 85deee382..4d165ece0 100644 --- a/script.coffee +++ b/script.coffee @@ -1076,7 +1076,6 @@ QR =
" - #$.bind $('#attach', qr), 'click', QR.attach #XXX use dom methods to set values instead of injecting raw user input into your html -_-; c = d.cookie $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' From 2ba552c59a92c2ae0eb5c7373269693c1396c453 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 20 Sep 2011 23:57:51 -0700 Subject: [PATCH 123/130] derp --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ecdd512cb..b8abeda96 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2934,7 +2934,7 @@ var data, origin; origin = e.origin, data = e.data; if (origin === 'http://sys.4chan.org') { - return QR.message(data); + return QR.receive(data); } }, css: '\ diff --git a/script.coffee b/script.coffee index 4d165ece0..1ba2f3ee7 100644 --- a/script.coffee +++ b/script.coffee @@ -2269,7 +2269,7 @@ Main = message: (e) -> {origin, data} = e if origin is 'http://sys.4chan.org' - QR.message data + QR.receive data css: ' /* dialog styling */ From d66a161f70f9df247cf78d0f3071bd1f9a52cccc Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 00:07:09 -0700 Subject: [PATCH 124/130] don't cache captcha when autoposting --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b8abeda96..d547d9d5f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1492,7 +1492,7 @@ } qr = QR.qr; $('.error', qr).textContent = ''; - if ((el = $('#recaptcha_response_field', qr)).value) { + if (e && (el = $('#recaptcha_response_field', qr)).value) { QR.captchaPush(el); } if (!(captcha = QR.captchaShift())) { diff --git a/script.coffee b/script.coffee index 1ba2f3ee7..9d0ec1563 100644 --- a/script.coffee +++ b/script.coffee @@ -1166,7 +1166,7 @@ QR = return {qr} = QR $('.error', qr).textContent = '' - if (el = $('#recaptcha_response_field', qr)).value + if e and (el = $('#recaptcha_response_field', qr)).value QR.captchaPush el if not captcha = QR.captchaShift() alert 'You forgot to type in the verification.' From 14f0a68bff2e3a5c3885b5bec64d16bd6ac8622f Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 00:18:07 -0700 Subject: [PATCH 125/130] use qr --- 4chan_x.user.js | 4 ++-- script.coffee | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d547d9d5f..f31250dba 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1443,7 +1443,7 @@ } return; data = JSON.parse(data); - $.extend($('a.error', QR.qr), data); + $.extend($('a.error', qr), data); tc = data.textContent; if (tc === 'Error: Duplicate file entry detected.') { if (row) { @@ -1458,7 +1458,7 @@ if (row) { $.rm(row); } - if (conf['Persistent QR'] || ((_ref2 = $('#files input', QR.qr)) != null ? _ref2.files.length : void 0)) { + if (conf['Persistent QR'] || ((_ref2 = $('#files input', qr)) != null ? _ref2.files.length : void 0)) { QR.reset(); } else { QR.close(); diff --git a/script.coffee b/script.coffee index 9d0ec1563..5c19f2d20 100644 --- a/script.coffee +++ b/script.coffee @@ -1136,7 +1136,7 @@ QR = window.location = data if QR.op return data = JSON.parse data - $.extend $('a.error', QR.qr), data + $.extend $('a.error', qr), data tc = data.textContent if tc is 'Error: Duplicate file entry detected.' $.rm row if row @@ -1145,7 +1145,7 @@ QR = setTimeout QR.submit, 1000 return $.rm row if row - if conf['Persistent QR'] or $('#files input', QR.qr)?.files.length + if conf['Persistent QR'] or $('#files input', qr)?.files.length QR.reset() else QR.close() @@ -1207,8 +1207,7 @@ QR = else if node = $ 'meta' data = node.content.match(/url=(.+)/)[1] parent.postMessage data, '*' - #parent will blank us on message receival; - #if we're not an iframe, we won't get blanked + #if we're an iframe, parent will blank us threading = init: -> From a37af47916a3dec6e039b53bd1728ab64c9d2f49 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 00:27:10 -0700 Subject: [PATCH 126/130] -e, +data --- 4chan_x.user.js | 5 ++--- script.coffee | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f31250dba..8b1d2f6c8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1431,12 +1431,11 @@ ta.focus(); return (_base = $('[name=resto]', qr)).value || (_base.value = tid); }, - receive: function(e) { - var cooldown, data, qr, row, tc, _ref, _ref2; + receive: function(data) { + var cooldown, qr, row, tc, _ref, _ref2; $('iframe[name=iframe]').src = 'about:blank'; qr = QR.qr; row = (_ref = $('#files input[form]', qr)) != null ? _ref.parentNode : void 0; - data = e.data; if (data) { if (QR.op) { window.location = data; diff --git a/script.coffee b/script.coffee index 5c19f2d20..fd407ad4b 100644 --- a/script.coffee +++ b/script.coffee @@ -1127,11 +1127,10 @@ QR = ta.setSelectionRange i, i ta.focus() $('[name=resto]', qr).value or= tid - receive: (e) -> + receive: (data) -> $('iframe[name=iframe]').src = 'about:blank' {qr} = QR row = $('#files input[form]', qr)?.parentNode - {data} = e if data window.location = data if QR.op return From f14c5b3a444389158487b278f95dfa4057c05917 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 01:17:49 -0700 Subject: [PATCH 127/130] rm qr message bind --- 4chan_x.user.js | 1 - script.coffee | 1 - 2 files changed, 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8b1d2f6c8..0fd6dfdc1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1213,7 +1213,6 @@ name: 'iframe', hidden: true })); - $.bind(window, 'message', QR.receive); $('#recaptcha_response_field').id = ''; holder = $('#recaptcha_challenge_field_holder'); $.bind(holder, 'DOMNodeInserted', QR.captchaNode); diff --git a/script.coffee b/script.coffee index fd407ad4b..9787d6290 100644 --- a/script.coffee +++ b/script.coffee @@ -939,7 +939,6 @@ QR = $.add d.body, $.el 'iframe', name: 'iframe' hidden: true - $.bind window, 'message', QR.receive # nuke id so qr's field focuses on recaptcha reload, instead of normal form's $('#recaptcha_response_field').id = '' holder = $ '#recaptcha_challenge_field_holder' From cdbfd99482d6caba6976dde8b25ed090176f3b07 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 01:18:31 -0700 Subject: [PATCH 128/130] whoops, return in if block --- 4chan_x.user.js | 2 +- script.coffee | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0fd6dfdc1..a9f3f762f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1438,8 +1438,8 @@ if (data) { if (QR.op) { window.location = data; + return; } - return; data = JSON.parse(data); $.extend($('a.error', qr), data); tc = data.textContent; diff --git a/script.coffee b/script.coffee index 9787d6290..17c5ab0de 100644 --- a/script.coffee +++ b/script.coffee @@ -1131,8 +1131,9 @@ QR = {qr} = QR row = $('#files input[form]', qr)?.parentNode if data - window.location = data if QR.op - return + if QR.op + window.location = data + return data = JSON.parse data $.extend $('a.error', qr), data tc = data.textContent From dcad8e16861e37df197a9f9dee5e9b8c97ab8764 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 01:20:07 -0700 Subject: [PATCH 129/130] send empty string if no error and not op --- 4chan_x.user.js | 3 +++ script.coffee | 1 + 2 files changed, 4 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index a9f3f762f..77b77af9e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1552,6 +1552,9 @@ }); } else if (node = $('meta')) { data = node.content.match(/url=(.+)/)[1]; + if (/#/.test(data)) { + data = ''; + } } return parent.postMessage(data, '*'); }); diff --git a/script.coffee b/script.coffee index 17c5ab0de..490913faf 100644 --- a/script.coffee +++ b/script.coffee @@ -1205,6 +1205,7 @@ QR = data = JSON.stringify {textContent, href} else if node = $ 'meta' data = node.content.match(/url=(.+)/)[1] + if /#/.test data then data = '' #not op parent.postMessage data, '*' #if we're an iframe, parent will blank us From 97bbe87e40ab418061fa7df310c3c78fd11fbf1a Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 21 Sep 2011 01:21:58 -0700 Subject: [PATCH 130/130] rm debugging alert --- 4chan_x.user.js | 1 - script.coffee | 1 - 2 files changed, 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 77b77af9e..928bd76dd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1545,7 +1545,6 @@ }; if (node = (_ref = $('table font b')) != null ? _ref.firstChild : void 0) { textContent = node.textContent, href = node.href; - alert(textContent); data = JSON.stringify({ textContent: textContent, href: href diff --git a/script.coffee b/script.coffee index 490913faf..6c203490d 100644 --- a/script.coffee +++ b/script.coffee @@ -1201,7 +1201,6 @@ QR = $ = (css) -> document.querySelector css if node = $('table font b')?.firstChild {textContent, href} = node - alert textContent data = JSON.stringify {textContent, href} else if node = $ 'meta' data = node.content.match(/url=(.+)/)[1]