From 74762bc9161ed5e17510c077a0942fe5d8baada6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 12:35:43 -0700 Subject: [PATCH 01/80] only scroll focused tabs --- 4chan_x.user.js | 10 +++++++++- script.coffee | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 399ef7904..1f6cd3e7d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1555,6 +1555,14 @@ updater = { init: function() { var checkbox, checked, dialog, html, input, name, title, _i, _len, _ref; + if (conf['Scrolling']) { + $.bind(window, 'focus', (function() { + return updater.focus = true; + })); + $.bind(window, 'blur', (function() { + return updater.focus = false; + })); + } html = "
-" + conf['Interval'] + "
"; checkbox = config.updater.checkbox; for (name in checkbox) { @@ -1644,7 +1652,7 @@ while ((reply = replies.pop()) && (reply.id > id)) { arr.push(reply.parentNode.parentNode.parentNode); } - scroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); + scroll = updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); updater.timer.textContent = '-' + conf['Interval']; if (conf['Verbose']) { updater.count.textContent = '+' + arr.length; diff --git a/script.coffee b/script.coffee index 90d29f708..af298c196 100644 --- a/script.coffee +++ b/script.coffee @@ -1255,6 +1255,9 @@ threadHiding = updater = init: -> + if conf['Scrolling'] + $.bind window, 'focus', (-> updater.focus = true) + $.bind window, 'blur', (-> updater.focus = false) html = "
-#{conf['Interval']}
" {checkbox} = config.updater for name of checkbox @@ -1330,7 +1333,7 @@ updater = while (reply = replies.pop()) and (reply.id > id) arr.push reply.parentNode.parentNode.parentNode #table - scroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) + scroll = updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) updater.timer.textContent = '-' + conf['Interval'] if conf['Verbose'] From 869f554e732ed371893ab31328a35be432e59668 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 12:42:13 -0700 Subject: [PATCH 02/80] changelog --- changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog b/changelog index 27155bcbc..2f039485f 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ github +- aeosynth: + - only auto scroll focused tabs (slightly buggy) 2.17.1 - mayhem: From 566672afe720b663f6162507d8fb2990863c6d6a Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 12:50:37 -0700 Subject: [PATCH 03/80] keybinds.cb -> keybinds --- 4chan_x.user.js | 264 ++++++++++++++++++++++++------------------------ script.coffee | 175 ++++++++++++++++---------------- 2 files changed, 218 insertions(+), 221 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1f6cd3e7d..ddd792d59 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -722,140 +722,138 @@ node = _ref[_i]; node.removeAttribute('accesskey'); } - return $.bind(d, 'keydown', keybinds.cb.keydown); + return $.bind(d, 'keydown', keybinds.keydown); }, - cb: { - keydown: function(e) { - var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; - if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { - return; - } - if (!(key = keybinds.cb.keyCode(e))) { - return; - } - thread = nav.getThread(); - switch (key) { - case conf.close: - if (o = $('#overlay')) { - $.rm(o); - } else if (qr.el) { - qr.close(); - } - break; - case conf.spoiler: - ta = e.target; - if (ta.nodeName !== 'TEXTAREA') { - return; - } - value = ta.value; - selStart = ta.selectionStart; - selEnd = ta.selectionEnd; - valStart = value.slice(0, selStart) + '[spoiler]'; - valMid = value.slice(selStart, selEnd); - valEnd = '[/spoiler]' + value.slice(selEnd); - ta.value = valStart + valMid + valEnd; - range = valStart.length + valMid.length; - ta.setSelectionRange(range, range); - break; - case conf.zero: - window.location = "/" + g.BOARD + "/0#0"; - break; - case conf.openEmptyQR: - keybinds.qr(thread); - break; - case conf.nextReply: - keybinds.hl.next(thread); - break; - case conf.previousReply: - keybinds.hl.prev(thread); - break; - case conf.expandAllImages: - keybinds.img(thread, true); - break; - case conf.openThread: - keybinds.open(thread); - break; - case conf.expandThread: - expandThread.toggle(thread); - break; - case conf.openQR: - keybinds.qr(thread, true); - break; - case conf.expandImages: - keybinds.img(thread); - break; - case conf.nextThread: - nav.next(); - break; - case conf.openThreadTab: - keybinds.open(thread, true); - break; - case conf.previousThread: - nav.prev(); - break; - case conf.update: - updater.update(); - break; - case conf.watch: - watcher.toggle(thread); - break; - case conf.hide: - threadHiding.toggle(thread); - break; - case conf.nextPage: - if ((_ref2 = $('input[value=Next]')) != null) { - _ref2.click(); - } - break; - case conf.previousPage: - if ((_ref3 = $('input[value=Previous]')) != null) { - _ref3.click(); - } - break; - case conf.submit: - if (qr.el) { - qr.submit.call($('form', qr.el)); - } else { - $('.postarea form').submit(); - } - break; - case conf.unreadCountTo0: - unread.replies.length = 0; - unread.updateTitle(); - Favicon.update(); - break; - default: - return; - } - return e.preventDefault(); - }, - keyCode: function(e) { - var kc; - kc = e.keyCode; - if ((65 <= kc && kc <= 90)) { - key = String.fromCharCode(kc); - if (!e.shiftKey) { - key = key.toLowerCase(); - } - } else if ((48 <= kc && kc <= 57)) { - key = String.fromCharCode(kc); - } else if (kc === 27) { - key = 'Esc'; - } else if (kc === 8) { - key = ''; - } else { - key = null; - } - if (key) { - if (e.altKey) { - key = 'alt+' + key; - } - if (e.ctrlKey) { - key = 'ctrl+' + key; - } - } - return key; + keydown: function(e) { + var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; + if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { + return; } + if (!(key = keybinds.keyCode(e))) { + return; + } + thread = nav.getThread(); + switch (key) { + case conf.close: + if (o = $('#overlay')) { + $.rm(o); + } else if (qr.el) { + qr.close(); + } + break; + case conf.spoiler: + ta = e.target; + if (ta.nodeName !== 'TEXTAREA') { + return; + } + value = ta.value; + selStart = ta.selectionStart; + selEnd = ta.selectionEnd; + valStart = value.slice(0, selStart) + '[spoiler]'; + valMid = value.slice(selStart, selEnd); + valEnd = '[/spoiler]' + value.slice(selEnd); + ta.value = valStart + valMid + valEnd; + range = valStart.length + valMid.length; + ta.setSelectionRange(range, range); + break; + case conf.zero: + window.location = "/" + g.BOARD + "/0#0"; + break; + case conf.openEmptyQR: + keybinds.qr(thread); + break; + case conf.nextReply: + keybinds.hl.next(thread); + break; + case conf.previousReply: + keybinds.hl.prev(thread); + break; + case conf.expandAllImages: + keybinds.img(thread, true); + break; + case conf.openThread: + keybinds.open(thread); + break; + case conf.expandThread: + expandThread.toggle(thread); + break; + case conf.openQR: + keybinds.qr(thread, true); + break; + case conf.expandImages: + keybinds.img(thread); + break; + case conf.nextThread: + nav.next(); + break; + case conf.openThreadTab: + keybinds.open(thread, true); + break; + case conf.previousThread: + nav.prev(); + break; + case conf.update: + updater.update(); + break; + case conf.watch: + watcher.toggle(thread); + break; + case conf.hide: + threadHiding.toggle(thread); + break; + case conf.nextPage: + if ((_ref2 = $('input[value=Next]')) != null) { + _ref2.click(); + } + break; + case conf.previousPage: + if ((_ref3 = $('input[value=Previous]')) != null) { + _ref3.click(); + } + break; + case conf.submit: + if (qr.el) { + qr.submit.call($('form', qr.el)); + } else { + $('.postarea form').submit(); + } + break; + case conf.unreadCountTo0: + unread.replies.length = 0; + unread.updateTitle(); + Favicon.update(); + break; + default: + return; + } + return e.preventDefault(); + }, + keyCode: function(e) { + var kc; + kc = e.keyCode; + if ((65 <= kc && kc <= 90)) { + key = String.fromCharCode(kc); + if (!e.shiftKey) { + key = key.toLowerCase(); + } + } else if ((48 <= kc && kc <= 57)) { + key = String.fromCharCode(kc); + } else if (kc === 27) { + key = 'Esc'; + } else if (kc === 8) { + key = ''; + } else { + key = null; + } + if (key) { + if (e.altKey) { + key = 'alt+' + key; + } + if (e.ctrlKey) { + key = 'ctrl+' + key; + } + } + return key; }, img: function(thread, all) { var root, thumb; @@ -1130,7 +1128,7 @@ keybind: function(e) { e.preventDefault(); e.stopPropagation(); - if ((key = keybinds.cb.keyCode(e)) == null) { + if ((key = keybinds.keyCode(e)) == null) { return; } this.value = key; diff --git a/script.coffee b/script.coffee index af298c196..adda1ebc2 100644 --- a/script.coffee +++ b/script.coffee @@ -515,100 +515,99 @@ keybinds = init: -> for node in $$ '[accesskey]' node.removeAttribute 'accesskey' - $.bind d, 'keydown', keybinds.cb.keydown + $.bind d, 'keydown', keybinds.keydown - cb: - keydown: (e) -> - return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) - return unless key = keybinds.cb.keyCode e + keydown: (e) -> + return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) + return unless key = keybinds.keyCode e - thread = nav.getThread() - switch key - when conf.close - if o = $ '#overlay' - $.rm o - else if qr.el - qr.close() - when conf.spoiler - ta = e.target - return unless ta.nodeName is 'TEXTAREA' + thread = nav.getThread() + switch key + when conf.close + if o = $ '#overlay' + $.rm o + else if qr.el + qr.close() + when conf.spoiler + ta = e.target + return unless ta.nodeName is 'TEXTAREA' - value = ta.value - selStart = ta.selectionStart - selEnd = ta.selectionEnd + value = ta.value + selStart = ta.selectionStart + selEnd = ta.selectionEnd - valStart = value[0...selStart] + '[spoiler]' - valMid = value[selStart...selEnd] - valEnd = '[/spoiler]' + value[selEnd..] + valStart = value[0...selStart] + '[spoiler]' + valMid = value[selStart...selEnd] + valEnd = '[/spoiler]' + value[selEnd..] - ta.value = valStart + valMid + valEnd - range = valStart.length + valMid.length - ta.setSelectionRange range, range - when conf.zero - window.location = "/#{g.BOARD}/0#0" - when conf.openEmptyQR - keybinds.qr thread - when conf.nextReply - keybinds.hl.next thread - when conf.previousReply - keybinds.hl.prev thread - when conf.expandAllImages - keybinds.img thread, true - when conf.openThread - keybinds.open thread - when conf.expandThread - expandThread.toggle thread - when conf.openQR - keybinds.qr thread, true - when conf.expandImages - keybinds.img thread - when conf.nextThread - nav.next() - when conf.openThreadTab - keybinds.open thread, true - when conf.previousThread - nav.prev() - when conf.update - updater.update() - when conf.watch - watcher.toggle thread - when conf.hide - threadHiding.toggle thread - when conf.nextPage - $('input[value=Next]')?.click() - when conf.previousPage - $('input[value=Previous]')?.click() - when conf.submit - if qr.el - qr.submit.call $ 'form', qr.el - else - $('.postarea form').submit() - when conf.unreadCountTo0 - unread.replies.length = 0 - unread.updateTitle() - Favicon.update() + ta.value = valStart + valMid + valEnd + range = valStart.length + valMid.length + ta.setSelectionRange range, range + when conf.zero + window.location = "/#{g.BOARD}/0#0" + when conf.openEmptyQR + keybinds.qr thread + when conf.nextReply + keybinds.hl.next thread + when conf.previousReply + keybinds.hl.prev thread + when conf.expandAllImages + keybinds.img thread, true + when conf.openThread + keybinds.open thread + when conf.expandThread + expandThread.toggle thread + when conf.openQR + keybinds.qr thread, true + when conf.expandImages + keybinds.img thread + when conf.nextThread + nav.next() + when conf.openThreadTab + keybinds.open thread, true + when conf.previousThread + nav.prev() + when conf.update + updater.update() + when conf.watch + watcher.toggle thread + when conf.hide + threadHiding.toggle thread + when conf.nextPage + $('input[value=Next]')?.click() + when conf.previousPage + $('input[value=Previous]')?.click() + when conf.submit + if qr.el + qr.submit.call $ 'form', qr.el else - return - e.preventDefault() - - keyCode: (e) -> - kc = e.keyCode - if 65 <= kc <= 90 #A-Z - key = String.fromCharCode kc - if !e.shiftKey - key = key.toLowerCase() - else if 48 <= kc <= 57 #0-9 - key = String.fromCharCode kc - else if kc is 27 - key = 'Esc' - else if kc is 8 - key = '' + $('.postarea form').submit() + when conf.unreadCountTo0 + unread.replies.length = 0 + unread.updateTitle() + Favicon.update() else - key = null - if key - if e.altKey then key = 'alt+' + key - if e.ctrlKey then key = 'ctrl+' + key - key + return + e.preventDefault() + + keyCode: (e) -> + kc = e.keyCode + if 65 <= kc <= 90 #A-Z + key = String.fromCharCode kc + if !e.shiftKey + key = key.toLowerCase() + else if 48 <= kc <= 57 #0-9 + key = String.fromCharCode kc + else if kc is 27 + key = 'Esc' + else if kc is 8 + key = '' + else + key = null + if key + if e.altKey then key = 'alt+' + key + if e.ctrlKey then key = 'ctrl+' + key + key img: (thread, all) -> if all @@ -893,7 +892,7 @@ options = keybind: (e) -> e.preventDefault() e.stopPropagation() - return unless (key = keybinds.cb.keyCode e)? + return unless (key = keybinds.keyCode e)? @value = key $.setValue @name, key conf[@name] = key From f38dd63a68f5aa31c356a57d10d687a346082157 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 12:53:56 -0700 Subject: [PATCH 04/80] more focus checks --- 4chan_x.user.js | 4 +++- script.coffee | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ddd792d59..90a75a68f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -726,6 +726,7 @@ }, keydown: function(e) { var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; + updater.focus = true; if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { return; } @@ -1650,7 +1651,7 @@ while ((reply = replies.pop()) && (reply.id > id)) { arr.push(reply.parentNode.parentNode.parentNode); } - scroll = updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); + scroll = conf['Scrolling'] && updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); updater.timer.textContent = '-' + conf['Interval']; if (conf['Verbose']) { updater.count.textContent = '+' + arr.length; @@ -2324,6 +2325,7 @@ }, scroll: function(e) { var bottom, height, i, reply, _len, _ref; + updater.focus = true; height = d.body.clientHeight; _ref = unread.replies; for (i = 0, _len = _ref.length; i < _len; i++) { diff --git a/script.coffee b/script.coffee index adda1ebc2..1d50ba75b 100644 --- a/script.coffee +++ b/script.coffee @@ -518,6 +518,7 @@ keybinds = $.bind d, 'keydown', keybinds.keydown keydown: (e) -> + updater.focus = true return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) return unless key = keybinds.keyCode e @@ -1332,7 +1333,7 @@ updater = while (reply = replies.pop()) and (reply.id > id) arr.push reply.parentNode.parentNode.parentNode #table - scroll = updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) + scroll = conf['Scrolling'] && updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) updater.timer.textContent = '-' + conf['Interval'] if conf['Verbose'] @@ -1770,6 +1771,7 @@ unread = Favicon.update() scroll: (e) -> + updater.focus = true height = d.body.clientHeight for reply, i in unread.replies {bottom} = reply.getBoundingClientRect() From 4830bda4c8f63f3b0339ed341185f3e5b9f01022 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 1 Aug 2011 00:11:49 +0200 Subject: [PATCH 05/80] Fix theoretical cooldown bug. --- 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 90a75a68f..62a79733a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1196,7 +1196,7 @@ cb: function() { var submit, submits, _i, _j, _len, _len2, _results; submits = $$('#com_submit'); - if (--cooldown.duration) { + if (--cooldown.duration > 0) { _results = []; for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; diff --git a/script.coffee b/script.coffee index 1d50ba75b..a4b3ce200 100644 --- a/script.coffee +++ b/script.coffee @@ -937,7 +937,7 @@ cooldown = cb: -> submits = $$ '#com_submit' - if --cooldown.duration + if --cooldown.duration > 0 for submit in submits submit.value = cooldown.duration else From b3a6f8f0b44319c1e9bcd0056e2e25a8c537f41f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 15:42:08 -0700 Subject: [PATCH 06/80] fix #206 --- 4chan_x.user.js | 3 +++ script.coffee | 2 ++ 2 files changed, 5 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 62a79733a..9925be6d3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2049,6 +2049,9 @@ }, toggle: function(e) { var el, hidden, id, inline, inlined, pathname, root, table, threadID, _i, _len, _ref; + if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) { + return; + } e.preventDefault(); /* https://bugzilla.mozilla.org/show_bug.cgi?id=674955 diff --git a/script.coffee b/script.coffee index a4b3ce200..c10d2d644 100644 --- a/script.coffee +++ b/script.coffee @@ -1589,6 +1589,8 @@ quoteInline = quote.removeAttribute 'onclick' $.bind quote, 'click', quoteInline.toggle toggle: (e) -> + return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0 + e.preventDefault() ### https://bugzilla.mozilla.org/show_bug.cgi?id=674955 From 0fc94a5bbce5574f70cf4d9585936eff83610525 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 15:46:33 -0700 Subject: [PATCH 07/80] changelog --- changelog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 2f039485f..de150fb47 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ github - aeosynth: - - only auto scroll focused tabs (slightly buggy) + - only auto scroll focused tabs + - quote inlining: only work on unmodified left-click 2.17.1 - mayhem: From 0c0a8c6dbd99becaf2ff3c111d7742d3a14ec03f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 15:50:35 -0700 Subject: [PATCH 08/80] s/auto_// --- 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 9925be6d3..ab4cb3e58 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1402,9 +1402,9 @@ c = $('b').lastChild; if (c.nodeType === 8) { _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; - noko = /auto_noko/.test(location.search); + noko = /noko/.test(location.search); if (thread === '0') { - if (/auto_watch/.test(location.search)) { + if (/watch/.test(location.search)) { return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; } else if (noko) { return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id; @@ -2716,7 +2716,7 @@ } threading.init(); if (conf['Auto Noko']) { - $('.postarea form').action += '?auto_noko'; + $('.postarea form').action += '?noko'; } if (conf['Cooldown']) { cooldown.init(); @@ -2808,7 +2808,7 @@ expandComment.init(); } if (conf['Auto Watch']) { - $('.postarea form').action += '?auto_watch'; + $('.postarea form').action += '?watch'; } } _ref3 = $$('div.op'); diff --git a/script.coffee b/script.coffee index c10d2d644..ee4ec26af 100644 --- a/script.coffee +++ b/script.coffee @@ -1127,9 +1127,9 @@ qr = if c.nodeType is 8 #comment node [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) - noko = /auto_noko/.test location.search + noko = /noko/.test location.search if thread is '0' - if /auto_watch/.test location.search + if /watch/.test location.search window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" else if noko window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}" @@ -2105,7 +2105,7 @@ main = threading.init() if conf['Auto Noko'] - $('.postarea form').action += '?auto_noko' + $('.postarea form').action += '?noko' if conf['Cooldown'] cooldown.init() @@ -2198,7 +2198,7 @@ main = expandComment.init() if conf['Auto Watch'] - $('.postarea form').action += '?auto_watch' + $('.postarea form').action += '?watch' for op in $$ 'div.op' for callback in g.callbacks From b61453fde10569f6fb83de5f48db52ba4342774c Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 16:23:05 -0700 Subject: [PATCH 09/80] simple url building --- 4chan_x.user.js | 41 ++++++++++++++++++++--------------------- script.coffee | 37 ++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ab4cb3e58..84d52e679 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1374,7 +1374,7 @@ return qr.el = null; }, sys: function() { - var c, duration, id, noko, recaptcha, thread, _, _ref; + var c, duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref; if (recaptcha = $('#recaptcha_response_field')) { $.bind(recaptcha, 'keydown', Recaptcha.listener); return; @@ -1402,28 +1402,27 @@ c = $('b').lastChild; if (c.nodeType === 8) { _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; - noko = /noko/.test(location.search); - if (thread === '0') { - if (/watch/.test(location.search)) { - return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; - } else if (noko) { - return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id; + 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 (noko) { + url += '/res/'; + url += thread === 0 ? id : thread; + if (watch) { + url += '?watch'; } - } else if (/cooldown/.test(location.search)) { - duration = Date.now() + 30000; - if (/sage/.test(location.search)) { - duration += 30000; - } - if (noko) { - return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "?cooldown=" + duration + "#" + id; - } else { - return window.location = "http://boards.4chan.org/" + g.BOARD + "?cooldown=" + duration; - } - } else if (noko) { - return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id; - } else { - return window.location = "http://boards.4chan.org/" + g.BOARD; } + if (cooldown) { + duration = Date.now() + (sage ? 60 : 30) * 1000; + url += '?cooldown=' + duration; + } + if (noko) { + url += '#' + id; + } + return window.location = url; } } }; diff --git a/script.coffee b/script.coffee index ee4ec26af..95ae25595 100644 --- a/script.coffee +++ b/script.coffee @@ -1127,23 +1127,26 @@ qr = if c.nodeType is 8 #comment node [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) - noko = /noko/.test location.search - if thread is '0' - if /watch/.test location.search - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" - else if noko - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}" - else if /cooldown/.test location.search - duration = Date.now() + 30000 - duration += 30000 if /sage/.test location.search - if noko - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}?cooldown=#{duration}##{id}" - else - window.location = "http://boards.4chan.org/#{g.BOARD}?cooldown=#{duration}" - else if noko - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}" - else - window.location = "http://boards.4chan.org/#{g.BOARD}" + {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 noko + url += '/res/' + url += if thread is 0 then id else thread + if watch + url += '?watch' + if cooldown + duration = Date.now() + (if sage then 60 else 30) * 1000 + url += '?cooldown=' + duration + if noko + url += '#' + id + + window.location = url threading = init: -> From 045ba0f6b941881ae69d34a809312f7568a34e91 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 16:24:43 -0700 Subject: [PATCH 10/80] watch test in search not hash --- 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 84d52e679..667a31af2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2790,7 +2790,7 @@ if (conf['Reply Navigation']) { nav.init(); } - if (conf['Auto Watch'] && conf['Thread Watcher'] && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) { + if (conf['Auto Watch'] && conf['Thread Watcher'] && /watch/.test(location.search && $('img.favicon').src === Favicon.empty)) { watcher.watch(null, g.THREAD_ID); } } else { diff --git a/script.coffee b/script.coffee index 95ae25595..184de7fc3 100644 --- a/script.coffee +++ b/script.coffee @@ -2184,7 +2184,7 @@ main = nav.init() if conf['Auto Watch'] and conf['Thread Watcher'] and - location.hash is '#watch' and $('img.favicon').src is Favicon.empty + /watch/.test location.search and $('img.favicon').src is Favicon.empty watcher.watch null, g.THREAD_ID else #not reply From 8bc50c1b77e64e724a461adafef5327e65f16627 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 16:25:28 -0700 Subject: [PATCH 11/80] look for watch in search not hash --- 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 667a31af2..a6e65867b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2790,7 +2790,7 @@ if (conf['Reply Navigation']) { nav.init(); } - if (conf['Auto Watch'] && conf['Thread Watcher'] && /watch/.test(location.search && $('img.favicon').src === Favicon.empty)) { + if (conf['Auto Watch'] && conf['Thread Watcher'] && /watch/.test(location.search) && $('img.favicon').src === Favicon.empty) { watcher.watch(null, g.THREAD_ID); } } else { diff --git a/script.coffee b/script.coffee index 184de7fc3..58f0f537e 100644 --- a/script.coffee +++ b/script.coffee @@ -2184,7 +2184,7 @@ main = nav.init() if conf['Auto Watch'] and conf['Thread Watcher'] and - /watch/.test location.search and $('img.favicon').src is Favicon.empty + /watch/.test(location.search) and $('img.favicon').src is Favicon.empty watcher.watch null, g.THREAD_ID else #not reply From 0775acbba3ddfc2ed7c0b93f60f30da18cdccf5d Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 16:33:48 -0700 Subject: [PATCH 12/80] d.getElementById -> $.id --- 4chan_x.user.js | 17 ++++++++++------- script.coffee | 16 +++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a6e65867b..3b2282ea3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -292,6 +292,9 @@ return object; }; $.extend($, { + id: function(id) { + return d.getElementById(id); + }, globalEval: function(code) { var script; script = $.el('script', { @@ -614,7 +617,7 @@ _results = []; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { backlink = _ref2[_i]; - _results.push(!d.getElementById(backlink.hash.slice(1)) ? $.rm(backlink) : void 0); + _results.push(!$.id(backlink.hash.slice(1)) ? $.rm(backlink) : void 0); } return _results; } @@ -1287,7 +1290,7 @@ watcher.watch(null, g.THREAD_ID); } else { id = $('input[name=resto]', qr.el).value; - op = d.getElementById(id); + op = $.id(id); if ($('img.favicon', op).src === Favicon.empty) { watcher.watch(op, id); } @@ -1997,7 +2000,7 @@ } _results = []; for (qid in quotes) { - if (!(el = d.getElementById(qid))) { + if (!(el = $.id(qid))) { continue; } if (!conf['OP Backlinks'] && el.className === 'op') { @@ -2072,14 +2075,14 @@ _ref = $$('input', table); for (_i = 0, _len = _ref.length; _i < _len; _i++) { inlined = _ref[_i]; - if (hidden = d.getElementById(inlined.name)) { + if (hidden = $.id(inlined.name)) { $.show($.x('ancestor::table[1]', hidden)); } } return; } root = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling ? this.nextSibling : this; - if (el = d.getElementById(id)) { + if (el = $.id(id)) { inline = quoteInline.table(id, el.innerHTML); if (this.className === 'backlink') { if ($("a.backlink[href='#" + id + "']", el)) { @@ -2175,7 +2178,7 @@ }); $.append(d.body, qp); id = this.hash.slice(1); - if (el = d.getElementById(id)) { + if (el = $.id(id)) { qp.innerHTML = el.innerHTML; if (conf['Quote Highlighting']) { $.addClass(el, 'qphl'); @@ -2200,7 +2203,7 @@ }, mouseout: function() { var el; - if (el = d.getElementById(this.hash.slice(1))) { + if (el = $.id(this.hash.slice(1))) { $.removeClass(el, 'qphl'); } return ui.hoverend(); diff --git a/script.coffee b/script.coffee index 58f0f537e..a30e0b394 100644 --- a/script.coffee +++ b/script.coffee @@ -200,6 +200,8 @@ $.extend = (object, properties) -> object $.extend $, + id: (id) -> + d.getElementById id globalEval: (code) -> script = $.el 'script', textContent: "(#{code})()" @@ -430,7 +432,7 @@ expandThread = while (prev = table.previousSibling) and (prev.nodeName is 'TABLE') $.rm prev for backlink in $$ '.op a.backlink' - $.rm backlink if !d.getElementById backlink.hash[1..] + $.rm backlink if !$.id backlink.hash[1..] parse: (req, pathname, thread, a) -> @@ -1008,7 +1010,7 @@ qr = watcher.watch null, g.THREAD_ID else id = $('input[name=resto]', qr.el).value - op = d.getElementById id + op = $.id id if $('img.favicon', op).src is Favicon.empty watcher.watch op, id @@ -1565,7 +1567,7 @@ quoteBacklink = #duplicate quotes get overwritten quotes[qid] = quote for qid of quotes - continue unless el = d.getElementById qid + continue unless el = $.id qid #don't backlink the op continue if !conf['OP Backlinks'] and el.className is 'op' link = $.el 'a', @@ -1613,11 +1615,11 @@ quoteInline = $.rm table $.removeClass @, 'inlined' for inlined in $$ 'input', table - if hidden = d.getElementById inlined.name + if hidden = $.id inlined.name $.show $.x 'ancestor::table[1]', hidden return root = if @parentNode.nodeName is 'FONT' then @parentNode else if @nextSibling then @nextSibling else @ - if el = d.getElementById id + if el = $.id id inline = quoteInline.table id, el.innerHTML if @className is 'backlink' return if $("a.backlink[href='##{id}']", el) @@ -1679,7 +1681,7 @@ quotePreview = $.append d.body, qp id = @hash[1..] - if el = d.getElementById id + if el = $.id id qp.innerHTML = el.innerHTML $.addClass el, 'qphl' if conf['Quote Highlighting'] if /backlink/.test @className @@ -1692,7 +1694,7 @@ quotePreview = threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id $.cache @pathname, (-> quotePreview.parse @, id, threadID) mouseout: -> - $.removeClass el, 'qphl' if el = d.getElementById @hash[1..] + $.removeClass el, 'qphl' if el = $.id @hash[1..] ui.hoverend() parse: (req, id, threadID) -> return unless (qp = ui.el) and (qp.innerHTML is "Loading #{id}...") From 6bd2353d1d266a94396a542f5d8d1da53a95ad3a Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 16:36:27 -0700 Subject: [PATCH 13/80] scroll to bottom if post isn't found. fixes #202 --- 4chan_x.user.js | 3 +++ script.coffee | 3 +++ 2 files changed, 6 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3b2282ea3..c44ba4257 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2716,6 +2716,9 @@ Recaptcha.init(); $.bind(form, 'submit', qr.submit); } + if ((id = location.hash.slice(1)) && !$.id(id)) { + scrollTo(0, d.body.scrollHeight); + } threading.init(); if (conf['Auto Noko']) { $('.postarea form').action += '?noko'; diff --git a/script.coffee b/script.coffee index a30e0b394..a7ea1d87a 100644 --- a/script.coffee +++ b/script.coffee @@ -2106,6 +2106,9 @@ main = Recaptcha.init() $.bind form, 'submit', qr.submit + if (id = location.hash[1..]) and !$.id id + scrollTo 0, d.body.scrollHeight + #major features threading.init() From d35e3f570c777441d575bc3555b338115e18b1ec Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 16:38:19 -0700 Subject: [PATCH 14/80] comment --- script.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script.coffee b/script.coffee index a7ea1d87a..dd075a9bc 100644 --- a/script.coffee +++ b/script.coffee @@ -2106,6 +2106,8 @@ main = Recaptcha.init() $.bind form, 'submit', qr.submit + # scroll to bottom if post isn't found + # thumbnail generation takes time if (id = location.hash[1..]) and !$.id id scrollTo 0, d.body.scrollHeight From 4bd116d2b30a17bb868bb5f91fc67f4184664e05 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 17:09:17 -0700 Subject: [PATCH 15/80] copy old textarea value --- 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 c44ba4257..527c68c6f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1358,6 +1358,7 @@ left: '0px' }, html); qr.refresh(); + $('textarea', qr.el).value = $('textarea').value; $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { return e.stopPropagation(); }); diff --git a/script.coffee b/script.coffee index dd075a9bc..97e68700d 100644 --- a/script.coffee +++ b/script.coffee @@ -1087,6 +1087,7 @@ qr = qr.el = ui.dialog 'qr', top: '0px', left: '0px', html qr.refresh() + $('textarea', qr.el).value = $('textarea').value $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() $.bind $('#autohide', qr.el), 'click', qr.cb.autohide From 9cee5c513382294602659fa18f9df2df7e84d05d Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 17:41:46 -0700 Subject: [PATCH 16/80] option: auto hide qr. fix #200 --- 4chan_x.user.js | 15 +++++++++++---- script.coffee | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 527c68c6f..714a6cd76 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -100,7 +100,8 @@ 'Auto Noko': [true, 'Always redirect to your post'], 'Cooldown': [true, 'Prevent \'flood detected\' errors'], 'Quick Reply': [true, 'Reply without leaving the page'], - 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] + 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'], + 'Auto Hide QR': [true, 'Automatically auto-hide the quick reply when posting'] }, Quoting: { 'Quote Backlinks': [true, 'Add quote backlinks'], @@ -1312,7 +1313,9 @@ this.submit(); } $('#error', qr.el).textContent = ''; - qr.autohide.set(); + if (conf['Auto Hide QR']) { + qr.autohide.set(); + } return qr.sage = /sage/i.test($('input[name=email]', this).value); } }, @@ -1371,7 +1374,9 @@ }, persist: function() { qr.dialog(); - return qr.autohide.set(); + if (conf['Auto Hide QR']) { + return qr.autohide.set(); + } }, close: function() { $.rm(qr.el); @@ -2443,7 +2448,9 @@ } if (e.keyCode === 13 && cooldown.duration) { $('#auto', qr.el).checked = true; - return qr.autohide.set(); + if (conf['Auto Hide QR']) { + return qr.autohide.set(); + } } }, reload: function() { diff --git a/script.coffee b/script.coffee index 97e68700d..ce19cfbe6 100644 --- a/script.coffee +++ b/script.coffee @@ -34,6 +34,7 @@ config = 'Cooldown': [true, 'Prevent \'flood detected\' errors'] 'Quick Reply': [true, 'Reply without leaving the page'] 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] + 'Auto Hide QR': [true, 'Automatically auto-hide the quick reply when posting'] Quoting: 'Quote Backlinks': [true, 'Add quote backlinks'] 'OP Backlinks': [false, 'Add backlinks to the OP'] @@ -1027,7 +1028,7 @@ qr = else if isQR if !e then @submit() $('#error', qr.el).textContent = '' - qr.autohide.set() + qr.autohide.set() if conf['Auto Hide QR'] qr.sage = /sage/i.test $('input[name=email]', @).value quote: (link) -> @@ -1100,7 +1101,7 @@ qr = persist: -> qr.dialog() - qr.autohide.set() + qr.autohide.set() if conf['Auto Hide QR'] close: -> $.rm qr.el @@ -1846,7 +1847,7 @@ Recaptcha = Recaptcha.reload() if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running $('#auto', qr.el).checked = true - qr.autohide.set() + qr.autohide.set() if conf['Auto Hide QR'] reload: -> window.location = 'javascript:Recaptcha.reload()' reloaded: (e) -> From 0a547dc8041c6dffc655cd1ac925f279a5539805 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 18:01:27 -0700 Subject: [PATCH 17/80] 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 714a6cd76..8f63a65b9 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1419,7 +1419,7 @@ url = "http://boards.4chan.org/" + g.BOARD; if (noko) { url += '/res/'; - url += thread === 0 ? id : thread; + url += thread === '0' ? id : thread; if (watch) { url += '?watch'; } diff --git a/script.coffee b/script.coffee index ce19cfbe6..1c34795d9 100644 --- a/script.coffee +++ b/script.coffee @@ -1141,7 +1141,7 @@ qr = if noko url += '/res/' - url += if thread is 0 then id else thread + url += if thread is '0' then id else thread if watch url += '?watch' if cooldown From 2c856a9ad502c037c75535dba7d329d0a15cc587 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 1 Aug 2011 03:05:33 +0200 Subject: [PATCH 18/80] watch has a superior priority to noko --- 4chan_x.user.js | 9 ++++----- script.coffee | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 527c68c6f..b4696b7a3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1412,12 +1412,11 @@ sage = /sage/.test(search); watch = /watch/.test(search); url = "http://boards.4chan.org/" + g.BOARD; - if (noko) { + if (watch && thread === '0') { + url += "/res/" + id + "?watch"; + } else if (noko) { url += '/res/'; - url += thread === 0 ? id : thread; - if (watch) { - url += '?watch'; - } + url += thread === '0' ? id : thread; } if (cooldown) { duration = Date.now() + (sage ? 60 : 30) * 1000; diff --git a/script.coffee b/script.coffee index 97e68700d..d4ed358ec 100644 --- a/script.coffee +++ b/script.coffee @@ -1138,11 +1138,11 @@ qr = url = "http://boards.4chan.org/#{g.BOARD}" - if noko + 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 watch - url += '?watch' + url += if thread is '0' then id else thread if cooldown duration = Date.now() + (if sage then 60 else 30) * 1000 url += '?cooldown=' + duration From d472cd68ad76b83c89af3cf398daea8be230a316 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 20:27:57 -0700 Subject: [PATCH 19/80] it begins --- 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 17a4b7555..d58757880 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1355,7 +1355,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' diff --git a/script.coffee b/script.coffee index 56fd50708..15b48f53c 100644 --- a/script.coffee +++ b/script.coffee @@ -1080,7 +1080,7 @@ qr =
-
+
From b094a4e4dddf9137abd5e2f57a3f55f5bf8816ad Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 20:40:18 -0700 Subject: [PATCH 20/80] check for post after op has been threaded --- 4chan_x.user.js | 2 +- script.coffee | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 17a4b7555..b92cc234b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2723,10 +2723,10 @@ Recaptcha.init(); $.bind(form, 'submit', qr.submit); } + threading.init(); if ((id = location.hash.slice(1)) && !$.id(id)) { scrollTo(0, d.body.scrollHeight); } - threading.init(); if (conf['Auto Noko']) { $('.postarea form').action += '?noko'; } diff --git a/script.coffee b/script.coffee index 56fd50708..b57115ab8 100644 --- a/script.coffee +++ b/script.coffee @@ -2108,14 +2108,14 @@ main = Recaptcha.init() $.bind form, 'submit', qr.submit + #major features + threading.init() + # scroll to bottom if post isn't found # thumbnail generation takes time if (id = location.hash[1..]) and !$.id id scrollTo 0, d.body.scrollHeight - #major features - threading.init() - if conf['Auto Noko'] $('.postarea form').action += '?noko' From 40d1b4808fbcdc944b5f875533915b9ee1567451 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 1 Aug 2011 06:03:52 +0200 Subject: [PATCH 21/80] Fix links in expanded threads. Close #198 --- 4chan_x.user.js | 21 ++++++++++++++------- changelog | 2 ++ script.coffee | 10 +++++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 17a4b7555..5584fc49a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -624,7 +624,7 @@ } }, parse: function(req, pathname, thread, a) { - var body, br, next, quote, table, tables, _i, _j, _len, _len2, _ref, _results; + var body, br, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; $.unbind(a, 'click', expandThread.cb.toggle); @@ -638,18 +638,25 @@ body = $.el('body', { innerHTML: req.responseText }); - _ref = $$('a.quotelink', body); + _ref = $$('td[id]', body); for (_i = 0, _len = _ref.length; _i < _len; _i++) { - quote = _ref[_i]; - if (quote.getAttribute('href') === quote.hash) { - quote.pathname = pathname; + reply = _ref[_i]; + _ref2 = $$('a.quotelink', reply); + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + quote = _ref2[_j]; + if (quote.getAttribute('href') === quote.hash) { + quote.pathname = pathname; + } } + link = $('a.quotejs', reply); + link.href = "res/" + thread.firstChild.id + "#" + reply.id; + link.nextSibling.href = "res/" + thread.firstChild.id + "#q" + reply.id; } tables = $$('form[name=delform] table', body); tables.pop(); _results = []; - for (_j = 0, _len2 = tables.length; _j < _len2; _j++) { - table = tables[_j]; + for (_k = 0, _len3 = tables.length; _k < _len3; _k++) { + table = tables[_k]; _results.push($.before(br, table)); } return _results; diff --git a/changelog b/changelog index de150fb47..1ad01c264 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ github +- mayhem: + - fix post links in expanded threads - aeosynth: - only auto scroll focused tabs - quote inlining: only work on unmodified left-click diff --git a/script.coffee b/script.coffee index 56fd50708..fcef6bc94 100644 --- a/script.coffee +++ b/script.coffee @@ -452,9 +452,13 @@ expandThread = body = $.el 'body', innerHTML: req.responseText - for quote in $$ 'a.quotelink', body - if quote.getAttribute('href') is quote.hash - quote.pathname = pathname + for reply in $$ 'td[id]', body + for quote in $$ 'a.quotelink', reply + if quote.getAttribute('href') is quote.hash + quote.pathname = pathname + link = $ 'a.quotejs', reply + link.href = "res/#{thread.firstChild.id}##{reply.id}" + link.nextSibling.href = "res/#{thread.firstChild.id}#q#{reply.id}" tables = $$ 'form[name=delform] table', body tables.pop() for table in tables From 2f3263ddacf01f04edaefd30a4f657197f763802 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 21:04:21 -0700 Subject: [PATCH 22/80] add file inputs --- 4chan_x.user.js | 9 ++++++++- script.coffee | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 80963f63d..c087829e6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1348,6 +1348,12 @@ $('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; return $('input[name=pwd]', qr.el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; }, + add: function() { + var file, files; + file = this.parentNode.nextElementSibling.cloneNode(true); + files = $('#files', qr.el); + return $.append(files, file); + }, dialog: function(link) { var THREAD_ID, challenge, html, spoiler, submitDisabled, submitValue; submitValue = $('#com_submit').value; @@ -1355,7 +1361,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1368,6 +1374,7 @@ $.bind($('#autohide', qr.el), 'click', qr.cb.autohide); $.bind($('a[name=close]', qr.el), 'click', qr.close); $.bind($('form', qr.el), 'submit', qr.submit); + $.bind($('a[name=add]', qr.el), 'click', qr.add); $.bind($('img', qr.el), 'click', Recaptcha.reload); $.bind($('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener); return $.append(d.body, qr.el); diff --git a/script.coffee b/script.coffee index 325446d85..30cfe9346 100644 --- a/script.coffee +++ b/script.coffee @@ -1058,6 +1058,11 @@ qr = $('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + add: -> + file = @parentNode.nextElementSibling.cloneNode true + files = $ '#files', qr.el + $.append files, file + dialog: (link) -> submitValue = $('#com_submit').value submitDisabled = if $('#com_submit').disabled then 'disabled' else '' @@ -1079,9 +1084,10 @@ qr =
-
- + +
+
" @@ -1094,6 +1100,7 @@ qr = $.bind $('#autohide', qr.el), 'click', qr.cb.autohide $.bind $('a[name=close]', qr.el), 'click', qr.close $.bind $('form', qr.el), 'submit', qr.submit + $.bind $('a[name=add]', qr.el), 'click', qr.add $.bind $('img', qr.el), 'click', Recaptcha.reload $.bind $('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener From f851ae5b27f31f688c3a6770d657e825ceeb1852 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 21:27:27 -0700 Subject: [PATCH 23/80] multiple files --- 4chan_x.user.js | 11 ++++++++--- script.coffee | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c087829e6..fa98213d7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1251,7 +1251,7 @@ } }, message: function(e) { - var data, duration; + var data, duration, file, oldFile; Recaptcha.reload(); $('iframe[name=iframe]').src = 'about:blank'; data = e.data; @@ -1262,8 +1262,13 @@ return; } if (qr.el) { - if (g.REPLY && conf['Persistent QR']) { + file = $('#files input', qr.el); + if (g.REPLY && (conf['Persistent QR'] || file)) { qr.refresh(); + if (file) { + oldFile = $('#qr_form input[type=file]', qr.el); + $.replace(oldFile, file); + } } else { qr.close(); } @@ -1361,7 +1366,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' diff --git a/script.coffee b/script.coffee index 30cfe9346..28814c9c9 100644 --- a/script.coffee +++ b/script.coffee @@ -988,8 +988,12 @@ qr = return if qr.el - if g.REPLY and conf['Persistent QR'] + file = $ '#files input', qr.el + if g.REPLY and (conf['Persistent QR'] or file) qr.refresh() + if file + oldFile = $ '#qr_form input[type=file]', qr.el + $.replace oldFile, file else qr.close() if conf['Cooldown'] @@ -1087,8 +1091,8 @@ qr =
-
+
" qr.el = ui.dialog 'qr', top: '0px', left: '0px', html From 7d4fda2f56a94a277ca799c87bef7eddbfa0c911 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 1 Aug 2011 06:38:19 +0200 Subject: [PATCH 24/80] Scroll only when you're supposed to. --- 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 6bf688ba0..063b26e9f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2731,7 +2731,7 @@ $.bind(form, 'submit', qr.submit); } threading.init(); - if ((id = location.hash.slice(1)) && !$.id(id)) { + if ((id = location.hash.slice(1)) && !$.id(id) && !/\D/.test(id)) { scrollTo(0, d.body.scrollHeight); } if (conf['Auto Noko']) { diff --git a/script.coffee b/script.coffee index fe1afb090..a6d83d699 100644 --- a/script.coffee +++ b/script.coffee @@ -2117,7 +2117,7 @@ main = # scroll to bottom if post isn't found # thumbnail generation takes time - if (id = location.hash[1..]) and !$.id id + if (id = location.hash[1..]) and !$.id(id) and !/\D/.test id scrollTo 0, d.body.scrollHeight if conf['Auto Noko'] From 291f43bb250e223dfc392598286212d43ae271ea Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 22:00:56 -0700 Subject: [PATCH 25/80] test string before dom --- 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 2c10db926..fe7630925 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2743,7 +2743,7 @@ $.bind(form, 'submit', qr.submit); } threading.init(); - if ((id = location.hash.slice(1)) && !$.id(id) && !/\D/.test(id)) { + if ((id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) { scrollTo(0, d.body.scrollHeight); } if (conf['Auto Noko']) { diff --git a/script.coffee b/script.coffee index 30f6ad5d1..afb5c8a8d 100644 --- a/script.coffee +++ b/script.coffee @@ -2128,7 +2128,7 @@ main = # scroll to bottom if post isn't found # thumbnail generation takes time - if (id = location.hash[1..]) and !$.id(id) and !/\D/.test id + if (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id) scrollTo 0, d.body.scrollHeight if conf['Auto Noko'] From ad0e5a28aeef578f58e38600c4817237c319f08e Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 22:22:08 -0700 Subject: [PATCH 26/80] push captcha --- 4chan_x.user.js | 15 ++++++++++++--- script.coffee | 12 ++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fe7630925..76bb7bb43 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1237,7 +1237,8 @@ }); $.append(d.body, iframe); $.bind(window, 'message', qr.cb.message); - return $('#recaptcha_response_field').id = ''; + $('#recaptcha_response_field').id = ''; + return qr.captcha = []; }, autohide: { set: function() { @@ -1296,6 +1297,13 @@ return qr.quote(this); } }, + push: function() { + this.nextSibling.textContent = qr.captcha.push({ + challenge: $('input[name=recaptcha_challenge_field]', qr.el).value, + response: this.value + }); + return Recaptcha.reload(); + }, submit: function(e) { var id, inputfile, isQR, op; if (conf['Auto Watch Reply'] && conf['Thread Watcher']) { @@ -1373,7 +1381,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -2467,8 +2475,9 @@ if (e.keyCode === 13 && cooldown.duration) { $('#auto', qr.el).checked = true; if (conf['Auto Hide QR']) { - return qr.autohide.set(); + qr.autohide.set(); } + return qr.push.call(this); } }, reload: function() { diff --git a/script.coffee b/script.coffee index afb5c8a8d..a8f61223d 100644 --- a/script.coffee +++ b/script.coffee @@ -966,6 +966,7 @@ qr = #hack - nuke id so it doesn't grab focus when reloading $('#recaptcha_response_field').id = '' + qr.captcha = [] autohide: set: -> @@ -1013,6 +1014,12 @@ qr = e.preventDefault() qr.quote @ + push: -> + @nextSibling.textContent = qr.captcha.push + challenge: $('input[name=recaptcha_challenge_field]', qr.el).value + response: @value + Recaptcha.reload() + submit: (e) -> if conf['Auto Watch Reply'] and conf['Thread Watcher'] if g.REPLY and $('img.favicon').src is Favicon.empty @@ -1092,9 +1099,9 @@ qr =
- +
-
+
@@ -1863,6 +1870,7 @@ Recaptcha = if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running $('#auto', qr.el).checked = true qr.autohide.set() if conf['Auto Hide QR'] + qr.push.call this reload: -> window.location = 'javascript:Recaptcha.reload()' reloaded: (e) -> From 39d1cdfae231b340f689dac4a30dd5965b1f0706 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 23:28:03 -0700 Subject: [PATCH 27/80] auto retry, keep auto checked across form reset --- 4chan_x.user.js | 22 +++++++++++++++++++--- script.coffee | 15 ++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 76bb7bb43..219d289bd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1222,7 +1222,7 @@ submit.value = 'Submit'; } if (qr.el && $('#auto', qr.el).checked) { - return qr.submit.call($('form', qr.el)); + return qr.auto(); } } } @@ -1267,6 +1267,9 @@ $('input[name=recaptcha_response_field]', qr.el).value = ''; $.extend($('#error', qr.el), JSON.parse(data)); qr.autohide.unset(); + if (data.textContent === 'You seem to have mistyped the verification.') { + qr.auto(); + } return; } if (qr.el) { @@ -1297,12 +1300,23 @@ return qr.quote(this); } }, + auto: function() { + var captcha, responseField; + responseField = $('input[name=recaptcha_response_field]', qr.el); + if (!responseField.value && (captcha = qr.captcha.shift())) { + $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge; + responseField.value = captcha.response; + responseField.nextSibling.textContent = qr.captcha.length; + } + return qr.submit.call($('form', qr.el)); + }, push: function() { this.nextSibling.textContent = qr.captcha.push({ challenge: $('input[name=recaptcha_challenge_field]', qr.el).value, response: this.value }); - return Recaptcha.reload(); + Recaptcha.reload(); + return this.value = ''; }, submit: function(e) { var id, inputfile, isQR, op; @@ -1361,8 +1375,10 @@ return ta.value += text; }, refresh: function() { - var c, m; + var auto, c, m; + auto = $('#auto', qr.el).checked; $('form', qr.el).reset(); + $('#auto', qr.el).checked = auto; c = d.cookie; $('input[name=name]', qr.el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; diff --git a/script.coffee b/script.coffee index a8f61223d..f09f2e951 100644 --- a/script.coffee +++ b/script.coffee @@ -953,7 +953,7 @@ cooldown = submit.disabled = false submit.value = 'Submit' if qr.el and $('#auto', qr.el).checked - qr.submit.call $ 'form', qr.el + qr.auto() qr = init: -> @@ -990,6 +990,8 @@ qr = $('input[name=recaptcha_response_field]', qr.el).value = '' $.extend $('#error', qr.el), JSON.parse data qr.autohide.unset() + if data.textContent is 'You seem to have mistyped the verification.' + qr.auto() return if qr.el @@ -1014,11 +1016,20 @@ qr = e.preventDefault() qr.quote @ + auto: -> + responseField = $ 'input[name=recaptcha_response_field]', qr.el + if !responseField.value and captcha = qr.captcha.shift() + $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge + responseField.value = captcha.response + responseField.nextSibling.textContent = qr.captcha.length + qr.submit.call $ 'form', qr.el + push: -> @nextSibling.textContent = qr.captcha.push challenge: $('input[name=recaptcha_challenge_field]', qr.el).value response: @value Recaptcha.reload() + @value = '' submit: (e) -> if conf['Auto Watch Reply'] and conf['Thread Watcher'] @@ -1067,7 +1078,9 @@ qr = ta.value += text refresh: -> + auto = $('#auto', qr.el).checked $('form', qr.el).reset() + $('#auto', qr.el).checked = auto c = d.cookie $('input[name=name]', qr.el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' $('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' From c740f53bfeb06203784f2feaccc76248fb3a6129 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 23:59:08 -0700 Subject: [PATCH 28/80] parse data --- 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 219d289bd..5f15bbd2e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1264,8 +1264,9 @@ $('iframe[name=iframe]').src = 'about:blank'; data = e.data; if (data) { + data = JSON.parse(data); + $.extend($('#error', qr.el), data); $('input[name=recaptcha_response_field]', qr.el).value = ''; - $.extend($('#error', qr.el), JSON.parse(data)); qr.autohide.unset(); if (data.textContent === 'You seem to have mistyped the verification.') { qr.auto(); diff --git a/script.coffee b/script.coffee index f09f2e951..f0aca2440 100644 --- a/script.coffee +++ b/script.coffee @@ -987,8 +987,9 @@ qr = {data} = e if data # error message + data = JSON.parse data + $.extend $('#error', qr.el), data $('input[name=recaptcha_response_field]', qr.el).value = '' - $.extend $('#error', qr.el), JSON.parse data qr.autohide.unset() if data.textContent is 'You seem to have mistyped the verification.' qr.auto() From 1d9415ecf91399e333f5a42cbbbc7904bd0ce181 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 00:00:46 -0700 Subject: [PATCH 29/80] fix file adding --- 4chan_x.user.js | 5 ++++- script.coffee | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5f15bbd2e..d1f0d0618 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1387,7 +1387,10 @@ }, add: function() { var file, files; - file = this.parentNode.nextElementSibling.cloneNode(true); + file = $.el('input', { + type: 'file', + name: 'upfile' + }); files = $('#files', qr.el); return $.append(files, file); }, diff --git a/script.coffee b/script.coffee index f0aca2440..4c01a7f04 100644 --- a/script.coffee +++ b/script.coffee @@ -1088,7 +1088,7 @@ qr = $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value add: -> - file = @parentNode.nextElementSibling.cloneNode true + file = $.el 'input', type: 'file', name: 'upfile' files = $ '#files', qr.el $.append files, file From 8200932c3b884d9f6bf0ce720c3322010c6d45a7 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 00:05:05 -0700 Subject: [PATCH 30/80] files css --- 4chan_x.user.js | 4 ++++ script.coffee | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index d1f0d0618..eb6cfef4c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3079,6 +3079,10 @@ [hidden] {\ display: none;\ }\ +\ + #files > input {\ + display: block;\ + }\ ' }; main.init(); diff --git a/script.coffee b/script.coffee index 4c01a7f04..13b2f7755 100644 --- a/script.coffee +++ b/script.coffee @@ -2445,6 +2445,10 @@ main = [hidden] { display: none; } + + #files > input { + display: block; + } ' main.init() From 8fd3bc48c3888c6a35b47bafa24fa111fd85a0af Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 00:28:42 -0700 Subject: [PATCH 31/80] changelog --- changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog b/changelog index 1ad01c264..1e70847d8 100644 --- a/changelog +++ b/changelog @@ -4,6 +4,13 @@ github - aeosynth: - only auto scroll focused tabs - quote inlining: only work on unmodified left-click + - select multiple files (one at a time) + - captcha caching + - qr: optional auto hiding + - copy old textarea value + - scroll to bottom of page if post isn't found (thumbnail generation takes + time) + - only scroll focused tabs 2.17.1 - mayhem: From f08093478148b8a4a2ff5c0452a63b5eaffd7f1c Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 12:50:50 -0700 Subject: [PATCH 32/80] time: %e, %k --- 4chan_x.user.js | 8 +++++++- script.coffee | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index eb6cfef4c..4f870ecdd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1053,7 +1053,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html @@ -1995,12 +1995,18 @@ d: function() { return this.zeroPad(this.date.getDate()); }, + e: function() { + return this.date.getDate(); + }, H: function() { return this.zeroPad(this.date.getHours()); }, I: function() { return this.zeroPad(this.date.getHours() % 12 || 12); }, + k: function() { + return this.date.getHours(); + }, m: function() { return this.zeroPad(this.date.getMonth() + 1); }, diff --git a/script.coffee b/script.coffee index 13b2f7755..586fb2dbc 100644 --- a/script.coffee +++ b/script.coffee @@ -799,8 +799,10 @@ options = %bmonth, abbreviatedJun %Bmonth, full lengthJune %dday of the month, zero padded03 + %eday of the month3 %Hhour (24 hour clock) zero padded13 %I (uppercase i)hour (12 hour clock) zero padded02 + %khour (24 hour clock)13 %mmonth, zero padded06 %Mminutes, zero padded54 %pupper case AM or PMPM @@ -1579,8 +1581,10 @@ Time = b: -> @month[@date.getMonth()][...3] B: -> @month[@date.getMonth()] d: -> @zeroPad @date.getDate() + e: -> @date.getDate() H: -> @zeroPad @date.getHours() I: -> @zeroPad @date.getHours() % 12 or 12 + k: -> @date.getHours() m: -> @zeroPad @date.getMonth() + 1 M: -> @zeroPad @date.getMinutes() p: -> if @date.getHours() < 12 then 'AM' else 'PM' From 951219daebc984b843cc8517ce66762538b19bf8 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 12:51:07 -0700 Subject: [PATCH 33/80] changelog --- changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog b/changelog index 1e70847d8..f2266742b 100644 --- a/changelog +++ b/changelog @@ -11,6 +11,7 @@ github - scroll to bottom of page if post isn't found (thumbnail generation takes time) - only scroll focused tabs + - time: %e, %k 2.17.1 - mayhem: From 84d7f26d1e8e3d65f835eeea414a0e7c081077b4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 12:59:12 -0700 Subject: [PATCH 34/80] more time reorganizing, headers --- 4chan_x.user.js | 2 +- script.coffee | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4f870ecdd..3f548eeed 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1053,7 +1053,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html diff --git a/script.coffee b/script.coffee index 586fb2dbc..a588c5d24 100644 --- a/script.coffee +++ b/script.coffee @@ -794,20 +794,27 @@ options = Format specifiers (source) SpecifierDescriptionValues/Example - %aweekday, abbreviatedSat - %Aweekday, fullSaturday + Year + %ytwo digit year00-99 + + Month %bmonth, abbreviatedJun %Bmonth, full lengthJune + %mmonth, zero padded06 + + Day + %aweekday, abbreviatedSat + %Aweekday, fullSaturday %dday of the month, zero padded03 %eday of the month3 + + Time %Hhour (24 hour clock) zero padded13 %I (uppercase i)hour (12 hour clock) zero padded02 %khour (24 hour clock)13 - %mmonth, zero padded06 %Mminutes, zero padded54 %pupper case AM or PMPM %Plower case am or pmpm - %ytwo digit year00-99 From e01e28a773678d959ae837b68f9e1bc132a76c40 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 12:59:40 -0700 Subject: [PATCH 35/80] 13 % 12 == 1 --- 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 3f548eeed..029578182 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1053,7 +1053,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html diff --git a/script.coffee b/script.coffee index a588c5d24..56f00c501 100644 --- a/script.coffee +++ b/script.coffee @@ -810,7 +810,7 @@ options = Time %Hhour (24 hour clock) zero padded13 - %I (uppercase i)hour (12 hour clock) zero padded02 + %I (uppercase i)hour (12 hour clock) zero padded01 %khour (24 hour clock)13 %Mminutes, zero padded54 %pupper case AM or PMPM From f1c0bd8b5f58c93d4bc60bbeadffca87352b97a3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 13:01:41 -0700 Subject: [PATCH 36/80] %l --- 4chan_x.user.js | 5 ++++- script.coffee | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 029578182..e6cc5e319 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1053,7 +1053,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html @@ -2007,6 +2007,9 @@ k: function() { return this.date.getHours(); }, + l: function() { + return this.date.getHours() % 12 || 12; + }, m: function() { return this.zeroPad(this.date.getMonth() + 1); }, diff --git a/script.coffee b/script.coffee index 56f00c501..600d0cef4 100644 --- a/script.coffee +++ b/script.coffee @@ -810,6 +810,7 @@ options = Time %Hhour (24 hour clock) zero padded13 + %l (lowercase L)hour (12 hour clock)1 %I (uppercase i)hour (12 hour clock) zero padded01 %khour (24 hour clock)13 %Mminutes, zero padded54 @@ -1592,6 +1593,7 @@ Time = H: -> @zeroPad @date.getHours() I: -> @zeroPad @date.getHours() % 12 or 12 k: -> @date.getHours() + l: -> @date.getHours() % 12 or 12 m: -> @zeroPad @date.getMonth() + 1 M: -> @zeroPad @date.getMinutes() p: -> if @date.getHours() < 12 then 'AM' else 'PM' From f236d2a7ebbc52fe81c2f35f8cbbaea1d513595b Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 13:03:33 -0700 Subject: [PATCH 37/80] changleog --- changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog b/changelog index f2266742b..eae893533 100644 --- a/changelog +++ b/changelog @@ -11,7 +11,7 @@ github - scroll to bottom of page if post isn't found (thumbnail generation takes time) - only scroll focused tabs - - time: %e, %k + - time: %e, %k, %l 2.17.1 - mayhem: From cf878694c307fe7bc2092b6f0835320edf2ddfb3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 13:03:57 -0700 Subject: [PATCH 38/80] more scroll checks --- 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 e6cc5e319..c40d64408 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2781,7 +2781,7 @@ $.bind(form, 'submit', qr.submit); } threading.init(); - if ((id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) { + if (g.REPLY && (id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) { scrollTo(0, d.body.scrollHeight); } if (conf['Auto Noko']) { diff --git a/script.coffee b/script.coffee index 600d0cef4..a53776ab6 100644 --- a/script.coffee +++ b/script.coffee @@ -2163,7 +2163,7 @@ main = # scroll to bottom if post isn't found # thumbnail generation takes time - if (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id) + if g.REPLY and (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id) scrollTo 0, d.body.scrollHeight if conf['Auto Noko'] From 11b78d8ec992a22a3a7bee297004fdf654f7c786 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 1 Aug 2011 16:41:48 -0700 Subject: [PATCH 39/80] s/upload/attach --- 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 c40d64408..a29b19870 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1401,7 +1401,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' diff --git a/script.coffee b/script.coffee index a53776ab6..a721d1a71 100644 --- a/script.coffee +++ b/script.coffee @@ -1125,7 +1125,7 @@ qr =
- +
From 3a9525938418a9c940efe1ba3d9456edfb6fcb9b Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 2 Aug 2011 09:53:25 -0700 Subject: [PATCH 40/80] derp, %e %k %l --- 4chan_x.user.js | 3 +++ script.coffee | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a29b19870..833fd6e85 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1956,8 +1956,11 @@ case 'b': case 'B': case 'd': + case 'e': case 'H': case 'I': + case 'k': + case 'l': case 'm': case 'M': case 'p': diff --git a/script.coffee b/script.coffee index a721d1a71..f3929a0b1 100644 --- a/script.coffee +++ b/script.coffee @@ -1557,7 +1557,7 @@ Time = foo: -> code = conf['time'].replace /%([A-Za-z])/g, (s, c) -> switch c - when 'a', 'A', 'b', 'B', 'd', 'H', 'I', 'm', 'M', 'p', 'P', 'y' then "' + Time.#{c}() + '" + when 'a', 'A', 'b', 'B', 'd', 'e', 'H', 'I', 'k', 'l', 'm', 'M', 'p', 'P', 'y' then "' + Time.#{c}() + '" else s Time.funk = Function 'Time', "return '#{code}'" day: [ From 48d9ecdb91e1dee8ac289c4ce83ea9368e10919c Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 2 Aug 2011 12:56:28 -0700 Subject: [PATCH 41/80] Revert "better hovering fix" This reverts commit 1bd822d4fbdb72a6500e13e6c5fdb101b93479e9. the cure is worse than the disease --- 4chan_x.user.js | 13 ------------- script.coffee | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 833fd6e85..3b982e91a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2119,19 +2119,6 @@ return; } e.preventDefault(); - /* - https://bugzilla.mozilla.org/show_bug.cgi?id=674955 - `mouseout` does not fire when element removed - RESOLVED INVALID - - inline a post, then hover over an inlined quote / image, then remove - the inlined post by clicking `enter` on the still-focused link - the - mouseout event doesn't fire, and the quote preview / image hover remains. - - we can prevent this sequence by `blur`-ing the clicked links. chrome - doesn't focus clicked links anyway. - */ - this.blur(); id = this.hash.slice(1); if (table = $("#i" + id, $.x('ancestor::td[1]', this))) { $.rm(table); diff --git a/script.coffee b/script.coffee index f3929a0b1..d16475f42 100644 --- a/script.coffee +++ b/script.coffee @@ -1648,19 +1648,6 @@ quoteInline = return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0 e.preventDefault() - ### - https://bugzilla.mozilla.org/show_bug.cgi?id=674955 - `mouseout` does not fire when element removed - RESOLVED INVALID - - inline a post, then hover over an inlined quote / image, then remove - the inlined post by clicking `enter` on the still-focused link - the - mouseout event doesn't fire, and the quote preview / image hover remains. - - we can prevent this sequence by `blur`-ing the clicked links. chrome - doesn't focus clicked links anyway. - ### - @blur() id = @hash[1..] if table = $ "#i#{id}", $.x 'ancestor::td[1]', @ $.rm table From 4aad7619767f7229fd748d0ae2e1532cd4a70383 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 2 Aug 2011 12:58:42 -0700 Subject: [PATCH 42/80] change --- changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog b/changelog index eae893533..e31f36c83 100644 --- a/changelog +++ b/changelog @@ -12,6 +12,7 @@ github time) - only scroll focused tabs - time: %e, %k, %l + - reverted hovering fix 2.17.1 - mayhem: From 20e3d8f697a169918b553cb75ebf9b75d92761d6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 2 Aug 2011 16:27:11 -0700 Subject: [PATCH 43/80] anonym.to --- 4chan_x.user.js | 2 +- script.coffee | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3b982e91a..3bfededcb 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -112,7 +112,7 @@ 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] } }, - flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://imgur.com/upload?url='].join('\n'), + flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://imgur.com/upload?url=', '#http://anonym.to/?'].join('\n'), time: '%m/%d/%y(%a)%H:%M', hotkeys: { close: 'Esc', diff --git a/script.coffee b/script.coffee index d16475f42..f70d510c1 100644 --- a/script.coffee +++ b/script.coffee @@ -49,6 +49,7 @@ config = '#http://tineye.com/search?url=' '#http://saucenao.com/search.php?db=999&url=' '#http://imgur.com/upload?url=' + '#http://anonym.to/?' ].join '\n' time: '%m/%d/%y(%a)%H:%M' hotkeys: From 3dbe03300ea446f43618af1a527a9220182cfbac Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 2 Aug 2011 16:32:04 -0700 Subject: [PATCH 44/80] DRY --- 4chan_x.user.js | 128 +++++++++++++++++++++--------------------------- script.coffee | 38 +++++++------- 2 files changed, 77 insertions(+), 89 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3bfededcb..7396a95c2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1950,26 +1950,10 @@ foo: function() { var code; code = conf['time'].replace(/%([A-Za-z])/g, function(s, c) { - switch (c) { - case 'a': - case 'A': - case 'b': - case 'B': - case 'd': - case 'e': - case 'H': - case 'I': - case 'k': - case 'l': - case 'm': - case 'M': - case 'p': - case 'P': - case 'y': - return "' + Time." + c + "() + '"; - break; - default: - return s; + if (c in Time.formatters) { + return "' + Time.formatters." + c + "() + '"; + } else { + return s; } }); return Time.funk = Function('Time', "return '" + code + "'"); @@ -1983,58 +1967,60 @@ return n; } }, - a: function() { - return this.day[this.date.getDay()].slice(0, 3); - }, - A: function() { - return this.day[this.date.getDay()]; - }, - b: function() { - return this.month[this.date.getMonth()].slice(0, 3); - }, - B: function() { - return this.month[this.date.getMonth()]; - }, - d: function() { - return this.zeroPad(this.date.getDate()); - }, - e: function() { - return this.date.getDate(); - }, - H: function() { - return this.zeroPad(this.date.getHours()); - }, - I: function() { - return this.zeroPad(this.date.getHours() % 12 || 12); - }, - k: function() { - return this.date.getHours(); - }, - l: function() { - return this.date.getHours() % 12 || 12; - }, - m: function() { - return this.zeroPad(this.date.getMonth() + 1); - }, - M: function() { - return this.zeroPad(this.date.getMinutes()); - }, - p: function() { - if (this.date.getHours() < 12) { - return 'AM'; - } else { - return 'PM'; + formatters: { + a: function() { + return Time.day[Time.date.getDay()].slice(0, 3); + }, + A: function() { + return Time.day[Time.date.getDay()]; + }, + b: function() { + return Time.month[Time.date.getMonth()].slice(0, 3); + }, + B: function() { + return Time.month[Time.date.getMonth()]; + }, + d: function() { + return Time.zeroPad(Time.date.getDate()); + }, + e: function() { + return Time.date.getDate(); + }, + H: function() { + return Time.zeroPad(Time.date.getHours()); + }, + I: function() { + return Time.zeroPad(Time.date.getHours() % 12 || 12); + }, + k: function() { + return Time.date.getHours(); + }, + l: function() { + return Time.date.getHours() % 12 || 12; + }, + m: function() { + return Time.zeroPad(Time.date.getMonth() + 1); + }, + M: function() { + return Time.zeroPad(Time.date.getMinutes()); + }, + p: function() { + if (Time.date.getHours() < 12) { + return 'AM'; + } else { + return 'PM'; + } + }, + P: function() { + if (Time.date.getHours() < 12) { + return 'am'; + } else { + return 'pm'; + } + }, + y: function() { + return Time.date.getFullYear() - 2000; } - }, - P: function() { - if (this.date.getHours() < 12) { - return 'am'; - } else { - return 'pm'; - } - }, - y: function() { - return this.date.getFullYear() - 2000; } }; titlePost = { diff --git a/script.coffee b/script.coffee index f70d510c1..555c0dfce 100644 --- a/script.coffee +++ b/script.coffee @@ -1557,9 +1557,10 @@ Time = $.replace s, time foo: -> code = conf['time'].replace /%([A-Za-z])/g, (s, c) -> - switch c - when 'a', 'A', 'b', 'B', 'd', 'e', 'H', 'I', 'k', 'l', 'm', 'M', 'p', 'P', 'y' then "' + Time.#{c}() + '" - else s + if c of Time.formatters + "' + Time.formatters.#{c}() + '" + else + s Time.funk = Function 'Time', "return '#{code}'" day: [ 'Sunday' @@ -1585,21 +1586,22 @@ Time = 'December' ] zeroPad: (n) -> if n < 10 then '0' + n else n - a: -> @day[@date.getDay()][...3] - A: -> @day[@date.getDay()] - b: -> @month[@date.getMonth()][...3] - B: -> @month[@date.getMonth()] - d: -> @zeroPad @date.getDate() - e: -> @date.getDate() - H: -> @zeroPad @date.getHours() - I: -> @zeroPad @date.getHours() % 12 or 12 - k: -> @date.getHours() - l: -> @date.getHours() % 12 or 12 - m: -> @zeroPad @date.getMonth() + 1 - M: -> @zeroPad @date.getMinutes() - p: -> if @date.getHours() < 12 then 'AM' else 'PM' - P: -> if @date.getHours() < 12 then 'am' else 'pm' - y: -> @date.getFullYear() - 2000 + formatters: + a: -> Time.day[Time.date.getDay()][...3] + A: -> Time.day[Time.date.getDay()] + b: -> Time.month[Time.date.getMonth()][...3] + B: -> Time.month[Time.date.getMonth()] + d: -> Time.zeroPad Time.date.getDate() + e: -> Time.date.getDate() + H: -> Time.zeroPad Time.date.getHours() + I: -> Time.zeroPad Time.date.getHours() % 12 or 12 + k: -> Time.date.getHours() + l: -> Time.date.getHours() % 12 or 12 + m: -> Time.zeroPad Time.date.getMonth() + 1 + M: -> Time.zeroPad Time.date.getMinutes() + p: -> if Time.date.getHours() < 12 then 'AM' else 'PM' + P: -> if Time.date.getHours() < 12 then 'am' else 'pm' + y: -> Time.date.getFullYear() - 2000 titlePost = init: -> From 9841d8001296aebc5244dbe48ec4ae84d83793ce Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 3 Aug 2011 09:44:28 -0700 Subject: [PATCH 45/80] mention cake build --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 97a0e5a67..d8ce516f4 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,5 @@ [install nodejs and npm](https://github.com/joyent/node/wiki/Installation), install [coffee-script](https://github.com/jashkenas/coffee-script/) with `npm install -g coffee-script`, clone 4chan x, cd into it and run -`npm link coffee-script`. actually build it with `cake dev &`. -kill the process with `killall node`. +`npm link coffee-script`. actually build it with `cake build`. for development +(continuous builds), run `cake dev &`. kill the process with `killall node`. From cb8f94628710de844b40f8df2c99f3431640e5d8 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 3 Aug 2011 10:07:55 -0700 Subject: [PATCH 46/80] installing --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d8ce516f4..304717e42 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +# Installing + +[bleeding edge](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) + +[stable](http://aeosynth.github.com/4chan-x) + # Building [install nodejs and npm](https://github.com/joyent/node/wiki/Installation), From 3f667086fbb674573549109d24eb7df5b5c58bc6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 3 Aug 2011 12:49:23 -0700 Subject: [PATCH 47/80] master --- 4chan_x.user.js | 4 ++-- header | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7396a95c2..615070a6a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2,12 +2,12 @@ // @name 4chan x // @namespace aeosynth // @description Adds various features. -// @version 2.17.1 +// @version master // @copyright 2009-2011 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* // @include http://sys.4chan.org/* -// @updateURL http://userscripts.org/scripts/source/51412.meta.js +// @updateURL https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js // ==/UserScript== /* LICENSE diff --git a/header b/header index de241b4a3..e39b88c21 100644 --- a/header +++ b/header @@ -2,12 +2,12 @@ // @name 4chan x // @namespace aeosynth // @description Adds various features. -// @version 2.17.1 +// @version master // @copyright 2009-2011 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* // @include http://sys.4chan.org/* -// @updateURL http://userscripts.org/scripts/source/51412.meta.js +// @updateURL https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js // ==/UserScript== /* LICENSE From 05b31dd81732ba228fcc48d5f2ea435def56f682 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 3 Aug 2011 12:50:09 -0700 Subject: [PATCH 48/80] readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 304717e42..ce195dacc 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Installing -[bleeding edge](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) +[master](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) -[stable](http://aeosynth.github.com/4chan-x) +[master](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) # Building From adadd4bab3f6aa6f720ec13d832b90f2fd986cd1 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 3 Aug 2011 12:51:02 -0700 Subject: [PATCH 49/80] derp --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce195dacc..c64f29266 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [master](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) -[master](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) +[stable](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) # Building From 6903d1fe85df831a158ebb329f3072f1852f136a Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 4 Aug 2011 09:43:29 -0700 Subject: [PATCH 50/80] branch description --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c64f29266..4dd469376 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Installing -[master](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) +[master](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) - bleeding edge. exciting new features, exciting new bugs. -[stable](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) +[stable](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) - stable. tries to be bug free. # Building From f3c5c286cb48792be8ded0c1e471dede55df97c5 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 4 Aug 2011 09:44:20 -0700 Subject: [PATCH 51/80] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4dd469376..03a41d8be 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [master](https://github.com/aeosynth/4chan-x/raw/master/4chan_x.user.js) - bleeding edge. exciting new features, exciting new bugs. -[stable](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) - stable. tries to be bug free. +[stable](https://github.com/aeosynth/4chan-x/raw/stable/4chan_x.user.js) - tries to be bug free. # Building From 2f7a5156215df06627a8a0af541190a1c50a8245 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 4 Aug 2011 16:38:22 -0700 Subject: [PATCH 52/80] rm uso link --- 4chan_x.user.js | 2 +- script.coffee | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 615070a6a..66688305e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1053,7 +1053,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html diff --git a/script.coffee b/script.coffee index 555c0dfce..63c98ce7c 100644 --- a/script.coffee +++ b/script.coffee @@ -780,7 +780,6 @@ options = From 0d192a6971cc13e34bf8ce54a46c816ffd259e5a Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 5 Aug 2011 00:19:06 -0700 Subject: [PATCH 53/80] select 'auto' when attaching multiple files --- 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 66688305e..fa6e98d68 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1387,6 +1387,7 @@ }, add: function() { var file, files; + $('#auto', qr.el).checked = true; file = $.el('input', { type: 'file', name: 'upfile' diff --git a/script.coffee b/script.coffee index 63c98ce7c..729254c20 100644 --- a/script.coffee +++ b/script.coffee @@ -1098,6 +1098,7 @@ qr = $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value add: -> + $('#auto', qr.el).checked = true file = $.el 'input', type: 'file', name: 'upfile' files = $ '#files', qr.el $.append files, file From c9555517aa7ef542a681d1a1cd7e95f70e2af83e Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 5 Aug 2011 01:47:18 -0700 Subject: [PATCH 54/80] qr overflow css --- 4chan_x.user.js | 3 +++ script.coffee | 3 +++ 2 files changed, 6 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index fa6e98d68..85f15f962 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2979,6 +2979,9 @@ \ #qr {\ position: fixed;\ + max-height: 100%;\ + overflow-x: hidden;\ + overflow-y: auto;\ }\ #qr > div.move {\ text-align: right;\ diff --git a/script.coffee b/script.coffee index 729254c20..865b67a0d 100644 --- a/script.coffee +++ b/script.coffee @@ -2362,6 +2362,9 @@ main = #qr { position: fixed; + max-height: 100%; + overflow-x: hidden; + overflow-y: auto; } #qr > div.move { text-align: right; From 3ea6292204300919c3fb368f43ea55ca0bb0015c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 5 Aug 2011 17:52:07 +0200 Subject: [PATCH 55/80] Fix 4chan X in closed threads. Close #221 --- 4chan_x.user.js | 8 ++++---- changelog | 1 + script.coffee | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 85f15f962..5e8437bf1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2761,10 +2761,10 @@ if (g.REPLY && (id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) { scrollTo(0, d.body.scrollHeight); } - if (conf['Auto Noko']) { - $('.postarea form').action += '?noko'; + if (conf['Auto Noko'] && form) { + form.action += '?noko'; } - if (conf['Cooldown']) { + if (conf['Cooldown'] && form) { cooldown.init(); } if (conf['Image Expansion']) { @@ -2822,7 +2822,7 @@ if (conf['Image Preloading']) { imgPreloading.init(); } - if (conf['Quick Reply'] && conf['Persistent QR']) { + if (conf['Quick Reply'] && conf['Persistent QR'] && form) { qr.persist(); } if (conf['Post in Title']) { diff --git a/changelog b/changelog index e31f36c83..0d84eb562 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ github - mayhem: - fix post links in expanded threads + - fix 4chan X in closed threads - aeosynth: - only auto scroll focused tabs - quote inlining: only work on unmodified left-click diff --git a/script.coffee b/script.coffee index 865b67a0d..ebae9d5b2 100644 --- a/script.coffee +++ b/script.coffee @@ -2156,10 +2156,10 @@ main = if g.REPLY and (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id) scrollTo 0, d.body.scrollHeight - if conf['Auto Noko'] - $('.postarea form').action += '?noko' + if conf['Auto Noko'] and form + form.action += '?noko' - if conf['Cooldown'] + if conf['Cooldown'] and form cooldown.init() if conf['Image Expansion'] @@ -2217,7 +2217,7 @@ main = if conf['Image Preloading'] imgPreloading.init() - if conf['Quick Reply'] and conf['Persistent QR'] + if conf['Quick Reply'] and conf['Persistent QR'] and form qr.persist() if conf['Post in Title'] From 490b7fd17eab9db26efc81deac2779ec5da4fd6b Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 5 Aug 2011 09:38:43 -0700 Subject: [PATCH 56/80] don't remember what canPost was for.... --- 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 5e8437bf1..2d7e48487 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2701,7 +2701,7 @@ }; main = { init: function() { - var DAY, callback, canPost, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6; + var DAY, callback, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6; pathname = location.pathname.substring(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { @@ -2753,7 +2753,7 @@ $.setValue('lastChecked', now); } $.addStyle(main.css); - if ((form = $('form[name=post]')) && (canPost = !!$('#recaptcha_response_field'))) { + if (form = $('form[name=post]')) { Recaptcha.init(); $.bind(form, 'submit', qr.submit); } @@ -2791,7 +2791,7 @@ if (conf['Reply Hiding']) { replyHiding.init(); } - if (canPost && conf['Quick Reply']) { + if (conf['Quick Reply'] && form) { qr.init(); } if (conf['Report Button']) { diff --git a/script.coffee b/script.coffee index ebae9d5b2..4f808b102 100644 --- a/script.coffee +++ b/script.coffee @@ -2144,7 +2144,7 @@ main = $.addStyle main.css - if (form = $ 'form[name=post]') and canPost = !!$ '#recaptcha_response_field' + if form = $ 'form[name=post]' Recaptcha.init() $.bind form, 'submit', qr.submit @@ -2186,7 +2186,7 @@ main = if conf['Reply Hiding'] replyHiding.init() - if canPost and conf['Quick Reply'] + if conf['Quick Reply'] and form qr.init() if conf['Report Button'] From 7ba86e79f63ba0e175d12194c35a2c298a35379d Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 5 Aug 2011 09:43:26 -0700 Subject: [PATCH 57/80] Revert "don't remember what canPost was for...." This reverts commit 490b7fd17eab9db26efc81deac2779ec5da4fd6b. it was for scriptish --- 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 2d7e48487..5e8437bf1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2701,7 +2701,7 @@ }; main = { init: function() { - var DAY, callback, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6; + var DAY, callback, canPost, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6; pathname = location.pathname.substring(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { @@ -2753,7 +2753,7 @@ $.setValue('lastChecked', now); } $.addStyle(main.css); - if (form = $('form[name=post]')) { + if ((form = $('form[name=post]')) && (canPost = !!$('#recaptcha_response_field'))) { Recaptcha.init(); $.bind(form, 'submit', qr.submit); } @@ -2791,7 +2791,7 @@ if (conf['Reply Hiding']) { replyHiding.init(); } - if (conf['Quick Reply'] && form) { + if (canPost && conf['Quick Reply']) { qr.init(); } if (conf['Report Button']) { diff --git a/script.coffee b/script.coffee index 4f808b102..ebae9d5b2 100644 --- a/script.coffee +++ b/script.coffee @@ -2144,7 +2144,7 @@ main = $.addStyle main.css - if form = $ 'form[name=post]' + if (form = $ 'form[name=post]') and canPost = !!$ '#recaptcha_response_field' Recaptcha.init() $.bind form, 'submit', qr.submit @@ -2186,7 +2186,7 @@ main = if conf['Reply Hiding'] replyHiding.init() - if conf['Quick Reply'] and form + if canPost and conf['Quick Reply'] qr.init() if conf['Report Button'] From a2ab28afb3c200b6b16f79cecc8a38a6d67783b4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 5 Aug 2011 09:45:46 -0700 Subject: [PATCH 58/80] canPost --- 4chan_x.user.js | 8 ++++---- script.coffee | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5e8437bf1..7d4a85d97 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2761,10 +2761,10 @@ if (g.REPLY && (id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) { scrollTo(0, d.body.scrollHeight); } - if (conf['Auto Noko'] && form) { + if (conf['Auto Noko'] && canPost) { form.action += '?noko'; } - if (conf['Cooldown'] && form) { + if (conf['Cooldown'] && canPost) { cooldown.init(); } if (conf['Image Expansion']) { @@ -2791,7 +2791,7 @@ if (conf['Reply Hiding']) { replyHiding.init(); } - if (canPost && conf['Quick Reply']) { + if (conf['Quick Reply'] && canPost) { qr.init(); } if (conf['Report Button']) { @@ -2822,7 +2822,7 @@ if (conf['Image Preloading']) { imgPreloading.init(); } - if (conf['Quick Reply'] && conf['Persistent QR'] && form) { + if (conf['Quick Reply'] && conf['Persistent QR'] && canPost) { qr.persist(); } if (conf['Post in Title']) { diff --git a/script.coffee b/script.coffee index ebae9d5b2..279660a04 100644 --- a/script.coffee +++ b/script.coffee @@ -2144,7 +2144,8 @@ main = $.addStyle main.css - if (form = $ 'form[name=post]') and canPost = !!$ '#recaptcha_response_field' + #recaptcha may be blocked, eg by noscript + if (form = $ 'form[name=post]') and (canPost = !!$ '#recaptcha_response_field') Recaptcha.init() $.bind form, 'submit', qr.submit @@ -2156,10 +2157,10 @@ main = if g.REPLY and (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id) scrollTo 0, d.body.scrollHeight - if conf['Auto Noko'] and form + if conf['Auto Noko'] and canPost form.action += '?noko' - if conf['Cooldown'] and form + if conf['Cooldown'] and canPost cooldown.init() if conf['Image Expansion'] @@ -2186,7 +2187,7 @@ main = if conf['Reply Hiding'] replyHiding.init() - if canPost and conf['Quick Reply'] + if conf['Quick Reply'] and canPost qr.init() if conf['Report Button'] @@ -2217,7 +2218,7 @@ main = if conf['Image Preloading'] imgPreloading.init() - if conf['Quick Reply'] and conf['Persistent QR'] and form + if conf['Quick Reply'] and conf['Persistent QR'] and canPost qr.persist() if conf['Post in Title'] From 066a3d8ba589d48a4a9d9d1002f52e89474f5176 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 09:41:10 -0700 Subject: [PATCH 59/80] title --- 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 7d4a85d97..e6c1bd7ce 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1402,7 +1402,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' diff --git a/script.coffee b/script.coffee index 279660a04..3f987d7fa 100644 --- a/script.coffee +++ b/script.coffee @@ -1124,7 +1124,7 @@ qr =
- +
From d330cbe8c95153e73f375ef9b00e80a43b64262f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 09:44:42 -0700 Subject: [PATCH 60/80] less qr.cb --- 4chan_x.user.js | 80 ++++++++++++++++++++++++------------------------- script.coffee | 68 ++++++++++++++++++++--------------------- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e6c1bd7ce..36c697908 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1230,13 +1230,13 @@ qr = { init: function() { var iframe; - g.callbacks.push(qr.cb.node); + g.callbacks.push(qr.node); iframe = $.el('iframe', { name: 'iframe', hidden: true }); $.append(d.body, iframe); - $.bind(window, 'message', qr.cb.message); + $.bind(window, 'message', qr.message); $('#recaptcha_response_field').id = ''; return qr.captcha = []; }, @@ -1250,6 +1250,44 @@ return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0; } }, + message: function(e) { + var data, duration, file, oldFile; + Recaptcha.reload(); + $('iframe[name=iframe]').src = 'about:blank'; + data = e.data; + if (data) { + data = JSON.parse(data); + $.extend($('#error', qr.el), data); + $('input[name=recaptcha_response_field]', qr.el).value = ''; + qr.autohide.unset(); + if (data.textContent === 'You seem to have mistyped the verification.') { + qr.auto(); + } + return; + } + if (qr.el) { + file = $('#files input', qr.el); + if (g.REPLY && (conf['Persistent QR'] || file)) { + qr.refresh(); + if (file) { + oldFile = $('#qr_form input[type=file]', qr.el); + $.replace(oldFile, file); + } + } else { + qr.close(); + } + } + if (conf['Cooldown']) { + duration = qr.sage ? 60 : 30; + $.setValue(g.BOARD + '/cooldown', Date.now() + duration * 1000); + return cooldown.start(); + } + }, + node: function(root) { + var quote; + quote = $('a.quotejs:not(:first-child)', root); + return $.bind(quote, 'click', qr.cb.quote); + }, cb: { autohide: function(e) { if (this.checked) { @@ -1258,44 +1296,6 @@ return $.removeClass(qr.el, 'auto'); } }, - message: function(e) { - var data, duration, file, oldFile; - Recaptcha.reload(); - $('iframe[name=iframe]').src = 'about:blank'; - data = e.data; - if (data) { - data = JSON.parse(data); - $.extend($('#error', qr.el), data); - $('input[name=recaptcha_response_field]', qr.el).value = ''; - qr.autohide.unset(); - if (data.textContent === 'You seem to have mistyped the verification.') { - qr.auto(); - } - return; - } - if (qr.el) { - file = $('#files input', qr.el); - if (g.REPLY && (conf['Persistent QR'] || file)) { - qr.refresh(); - if (file) { - oldFile = $('#qr_form input[type=file]', qr.el); - $.replace(oldFile, file); - } - } else { - qr.close(); - } - } - if (conf['Cooldown']) { - duration = qr.sage ? 60 : 30; - $.setValue(g.BOARD + '/cooldown', Date.now() + duration * 1000); - return cooldown.start(); - } - }, - node: function(root) { - var quote; - quote = $('a.quotejs:not(:first-child)', root); - return $.bind(quote, 'click', qr.cb.quote); - }, quote: function(e) { e.preventDefault(); return qr.quote(this); diff --git a/script.coffee b/script.coffee index 3f987d7fa..a0387cc81 100644 --- a/script.coffee +++ b/script.coffee @@ -967,12 +967,12 @@ cooldown = qr = init: -> - g.callbacks.push qr.cb.node + g.callbacks.push qr.node iframe = $.el 'iframe', name: 'iframe' hidden: true $.append d.body, iframe - $.bind window, 'message', qr.cb.message + $.bind window, 'message', qr.message #hack - nuke id so it doesn't grab focus when reloading $('#recaptcha_response_field').id = '' @@ -984,6 +984,38 @@ qr = unset: -> $('#autohide:checked', qr.el)?.click() + message: (e) -> + Recaptcha.reload() + $('iframe[name=iframe]').src = 'about:blank' + + {data} = e + if data # error message + data = JSON.parse data + $.extend $('#error', qr.el), data + $('input[name=recaptcha_response_field]', qr.el).value = '' + qr.autohide.unset() + if data.textContent is 'You seem to have mistyped the verification.' + qr.auto() + return + + if qr.el + file = $ '#files input', qr.el + if g.REPLY and (conf['Persistent QR'] or file) + qr.refresh() + if file + oldFile = $ '#qr_form input[type=file]', qr.el + $.replace oldFile, file + else + qr.close() + if conf['Cooldown'] + duration = if qr.sage then 60 else 30 + $.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000 + cooldown.start() + + node: (root) -> + quote = $ 'a.quotejs:not(:first-child)', root + $.bind quote, 'click', qr.cb.quote + cb: autohide: (e) -> if @checked @@ -991,38 +1023,6 @@ qr = else $.removeClass qr.el, 'auto' - message: (e) -> - Recaptcha.reload() - $('iframe[name=iframe]').src = 'about:blank' - - {data} = e - if data # error message - data = JSON.parse data - $.extend $('#error', qr.el), data - $('input[name=recaptcha_response_field]', qr.el).value = '' - qr.autohide.unset() - if data.textContent is 'You seem to have mistyped the verification.' - qr.auto() - return - - if qr.el - file = $ '#files input', qr.el - if g.REPLY and (conf['Persistent QR'] or file) - qr.refresh() - if file - oldFile = $ '#qr_form input[type=file]', qr.el - $.replace oldFile, file - else - qr.close() - if conf['Cooldown'] - duration = if qr.sage then 60 else 30 - $.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000 - cooldown.start() - - node: (root) -> - quote = $ 'a.quotejs:not(:first-child)', root - $.bind quote, 'click', qr.cb.quote - quote: (e) -> e.preventDefault() qr.quote @ From cfb5f0e05a94a50a96f47ca2da063666add48f84 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 09:47:16 -0700 Subject: [PATCH 61/80] alphabetize qr --- 4chan_x.user.js | 194 +++++++++++++++++++++--------------------- script.coffee | 220 ++++++++++++++++++++++++------------------------ 2 files changed, 207 insertions(+), 207 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 36c697908..6f62a05ed 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1240,6 +1240,26 @@ $('#recaptcha_response_field').id = ''; return qr.captcha = []; }, + add: function() { + var file, files; + $('#auto', qr.el).checked = true; + file = $.el('input', { + type: 'file', + name: 'upfile' + }); + files = $('#files', qr.el); + return $.append(files, file); + }, + auto: function() { + var captcha, responseField; + responseField = $('input[name=recaptcha_response_field]', qr.el); + if (!responseField.value && (captcha = qr.captcha.shift())) { + $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge; + responseField.value = captcha.response; + responseField.nextSibling.textContent = qr.captcha.length; + } + return qr.submit.call($('form', qr.el)); + }, autohide: { set: function() { var _ref; @@ -1250,6 +1270,48 @@ return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0; } }, + cb: { + autohide: function(e) { + if (this.checked) { + return $.addClass(qr.el, 'auto'); + } else { + return $.removeClass(qr.el, 'auto'); + } + }, + quote: function(e) { + e.preventDefault(); + return qr.quote(this); + } + }, + close: function() { + $.rm(qr.el); + return qr.el = null; + }, + dialog: function(link) { + var THREAD_ID, challenge, html, spoiler, submitDisabled, submitValue; + submitValue = $('#com_submit').value; + submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; + THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; + spoiler = $('.postarea label') ? '' : ''; + challenge = $('input[name=recaptcha_challenge_field]').value; + html = "
Quick Reply X
" + spoiler + "
"; + qr.el = ui.dialog('qr', { + top: '0px', + left: '0px' + }, html); + qr.refresh(); + $('textarea', qr.el).value = $('textarea').value; + $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { + return e.stopPropagation(); + }); + $.bind($('#autohide', qr.el), 'click', qr.cb.autohide); + $.bind($('a[name=close]', qr.el), 'click', qr.close); + $.bind($('form', qr.el), 'submit', qr.submit); + $.bind($('a[name=add]', qr.el), 'click', qr.add); + $.bind($('img', qr.el), 'click', Recaptcha.reload); + $.bind($('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener); + return $.append(d.body, qr.el); + }, message: function(e) { var data, duration, file, oldFile; Recaptcha.reload(); @@ -1288,29 +1350,12 @@ quote = $('a.quotejs:not(:first-child)', root); return $.bind(quote, 'click', qr.cb.quote); }, - cb: { - autohide: function(e) { - if (this.checked) { - return $.addClass(qr.el, 'auto'); - } else { - return $.removeClass(qr.el, 'auto'); - } - }, - quote: function(e) { - e.preventDefault(); - return qr.quote(this); + persist: function() { + qr.dialog(); + if (conf['Auto Hide QR']) { + return qr.autohide.set(); } }, - auto: function() { - var captcha, responseField; - responseField = $('input[name=recaptcha_response_field]', qr.el); - if (!responseField.value && (captcha = qr.captcha.shift())) { - $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge; - responseField.value = captcha.response; - responseField.nextSibling.textContent = qr.captcha.length; - } - return qr.submit.call($('form', qr.el)); - }, push: function() { this.nextSibling.textContent = qr.captcha.push({ challenge: $('input[name=recaptcha_challenge_field]', qr.el).value, @@ -1319,6 +1364,37 @@ Recaptcha.reload(); return this.value = ''; }, + quote: function(link) { + var id, s, selection, selectionID, ta, text, _ref; + if (qr.el) { + qr.autohide.unset(); + } else { + qr.dialog(link); + } + id = link.textContent; + text = ">>" + id + "\n"; + selection = window.getSelection(); + if (s = selection.toString()) { + selectionID = (_ref = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)) != null ? _ref.name : void 0; + if (selectionID === id) { + s = s.replace(/\n/g, '\n>'); + text += ">" + s + "\n"; + } + } + ta = $('textarea', qr.el); + ta.focus(); + return ta.value += text; + }, + refresh: function() { + var auto, c, m; + auto = $('#auto', qr.el).checked; + $('form', qr.el).reset(); + $('#auto', qr.el).checked = auto; + c = d.cookie; + $('input[name=name]', qr.el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + return $('input[name=pwd]', qr.el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; + }, submit: function(e) { var id, inputfile, isQR, op; if (conf['Auto Watch Reply'] && conf['Thread Watcher']) { @@ -1354,82 +1430,6 @@ return qr.sage = /sage/i.test($('input[name=email]', this).value); } }, - quote: function(link) { - var id, s, selection, selectionID, ta, text, _ref; - if (qr.el) { - qr.autohide.unset(); - } else { - qr.dialog(link); - } - id = link.textContent; - text = ">>" + id + "\n"; - selection = window.getSelection(); - if (s = selection.toString()) { - selectionID = (_ref = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)) != null ? _ref.name : void 0; - if (selectionID === id) { - s = s.replace(/\n/g, '\n>'); - text += ">" + s + "\n"; - } - } - ta = $('textarea', qr.el); - ta.focus(); - return ta.value += text; - }, - refresh: function() { - var auto, c, m; - auto = $('#auto', qr.el).checked; - $('form', qr.el).reset(); - $('#auto', qr.el).checked = auto; - c = d.cookie; - $('input[name=name]', qr.el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - return $('input[name=pwd]', qr.el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; - }, - add: function() { - var file, files; - $('#auto', qr.el).checked = true; - file = $.el('input', { - type: 'file', - name: 'upfile' - }); - files = $('#files', qr.el); - return $.append(files, file); - }, - dialog: function(link) { - var THREAD_ID, challenge, html, spoiler, submitDisabled, submitValue; - submitValue = $('#com_submit').value; - submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; - THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; - spoiler = $('.postarea label') ? '' : ''; - challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; - qr.el = ui.dialog('qr', { - top: '0px', - left: '0px' - }, html); - qr.refresh(); - $('textarea', qr.el).value = $('textarea').value; - $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { - return e.stopPropagation(); - }); - $.bind($('#autohide', qr.el), 'click', qr.cb.autohide); - $.bind($('a[name=close]', qr.el), 'click', qr.close); - $.bind($('form', qr.el), 'submit', qr.submit); - $.bind($('a[name=add]', qr.el), 'click', qr.add); - $.bind($('img', qr.el), 'click', Recaptcha.reload); - $.bind($('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener); - return $.append(d.body, qr.el); - }, - persist: function() { - qr.dialog(); - if (conf['Auto Hide QR']) { - return qr.autohide.set(); - } - }, - close: function() { - $.rm(qr.el); - return qr.el = null; - }, sys: function() { var c, duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref; if (recaptcha = $('#recaptcha_response_field')) { diff --git a/script.coffee b/script.coffee index a0387cc81..76b0fa0f6 100644 --- a/script.coffee +++ b/script.coffee @@ -978,44 +978,26 @@ qr = $('#recaptcha_response_field').id = '' qr.captcha = [] + add: -> + $('#auto', qr.el).checked = true + file = $.el 'input', type: 'file', name: 'upfile' + files = $ '#files', qr.el + $.append files, file + + auto: -> + responseField = $ 'input[name=recaptcha_response_field]', qr.el + if !responseField.value and captcha = qr.captcha.shift() + $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge + responseField.value = captcha.response + responseField.nextSibling.textContent = qr.captcha.length + qr.submit.call $ 'form', qr.el + autohide: set: -> $('#autohide:not(:checked)', qr.el)?.click() unset: -> $('#autohide:checked', qr.el)?.click() - message: (e) -> - Recaptcha.reload() - $('iframe[name=iframe]').src = 'about:blank' - - {data} = e - if data # error message - data = JSON.parse data - $.extend $('#error', qr.el), data - $('input[name=recaptcha_response_field]', qr.el).value = '' - qr.autohide.unset() - if data.textContent is 'You seem to have mistyped the verification.' - qr.auto() - return - - if qr.el - file = $ '#files input', qr.el - if g.REPLY and (conf['Persistent QR'] or file) - qr.refresh() - if file - oldFile = $ '#qr_form input[type=file]', qr.el - $.replace oldFile, file - else - qr.close() - if conf['Cooldown'] - duration = if qr.sage then 60 else 30 - $.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000 - cooldown.start() - - node: (root) -> - quote = $ 'a.quotejs:not(:first-child)', root - $.bind quote, 'click', qr.cb.quote - cb: autohide: (e) -> if @checked @@ -1027,81 +1009,9 @@ qr = e.preventDefault() qr.quote @ - auto: -> - responseField = $ 'input[name=recaptcha_response_field]', qr.el - if !responseField.value and captcha = qr.captcha.shift() - $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge - responseField.value = captcha.response - responseField.nextSibling.textContent = qr.captcha.length - qr.submit.call $ 'form', qr.el - - push: -> - @nextSibling.textContent = qr.captcha.push - challenge: $('input[name=recaptcha_challenge_field]', qr.el).value - response: @value - Recaptcha.reload() - @value = '' - - submit: (e) -> - if conf['Auto Watch Reply'] and conf['Thread Watcher'] - if g.REPLY and $('img.favicon').src is Favicon.empty - watcher.watch null, g.THREAD_ID - else - id = $('input[name=resto]', qr.el).value - op = $.id id - if $('img.favicon', op).src is Favicon.empty - watcher.watch op, id - - isQR = @id is 'qr_form' - - inputfile = $('input[type=file]', @) - if inputfile.value and inputfile.files[0].size > $('input[name=MAX_FILE_SIZE]').value - e.preventDefault() if e - if isQR - $('#error', qr.el).textContent = 'Error: File too large.' - else - alert 'Error: File too large.' - - else if isQR - if !e then @submit() - $('#error', qr.el).textContent = '' - qr.autohide.set() if conf['Auto Hide QR'] - qr.sage = /sage/i.test $('input[name=email]', @).value - - quote: (link) -> - if qr.el - qr.autohide.unset() - else - qr.dialog link - - id = link.textContent - text = ">>#{id}\n" - - selection = window.getSelection() - if s = selection.toString() - selectionID = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)?.name - if selectionID == id - s = s.replace /\n/g, '\n>' - text += ">#{s}\n" - - ta = $ 'textarea', qr.el - ta.focus() - ta.value += text - - refresh: -> - auto = $('#auto', qr.el).checked - $('form', qr.el).reset() - $('#auto', qr.el).checked = auto - c = d.cookie - $('input[name=name]', qr.el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' - $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - - add: -> - $('#auto', qr.el).checked = true - file = $.el 'input', type: 'file', name: 'upfile' - files = $ '#files', qr.el - $.append files, file + close: -> + $.rm qr.el + qr.el = null dialog: (link) -> submitValue = $('#com_submit').value @@ -1146,13 +1056,103 @@ qr = $.append d.body, qr.el + message: (e) -> + Recaptcha.reload() + $('iframe[name=iframe]').src = 'about:blank' + + {data} = e + if data # error message + data = JSON.parse data + $.extend $('#error', qr.el), data + $('input[name=recaptcha_response_field]', qr.el).value = '' + qr.autohide.unset() + if data.textContent is 'You seem to have mistyped the verification.' + qr.auto() + return + + if qr.el + file = $ '#files input', qr.el + if g.REPLY and (conf['Persistent QR'] or file) + qr.refresh() + if file + oldFile = $ '#qr_form input[type=file]', qr.el + $.replace oldFile, file + else + qr.close() + if conf['Cooldown'] + duration = if qr.sage then 60 else 30 + $.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000 + cooldown.start() + + node: (root) -> + quote = $ 'a.quotejs:not(:first-child)', root + $.bind quote, 'click', qr.cb.quote + persist: -> qr.dialog() qr.autohide.set() if conf['Auto Hide QR'] - close: -> - $.rm qr.el - qr.el = null + push: -> + @nextSibling.textContent = qr.captcha.push + challenge: $('input[name=recaptcha_challenge_field]', qr.el).value + response: @value + Recaptcha.reload() + @value = '' + + quote: (link) -> + if qr.el + qr.autohide.unset() + else + qr.dialog link + + id = link.textContent + text = ">>#{id}\n" + + selection = window.getSelection() + if s = selection.toString() + selectionID = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)?.name + if selectionID == id + s = s.replace /\n/g, '\n>' + text += ">#{s}\n" + + ta = $ 'textarea', qr.el + ta.focus() + ta.value += text + + refresh: -> + auto = $('#auto', qr.el).checked + $('form', qr.el).reset() + $('#auto', qr.el).checked = auto + c = d.cookie + $('input[name=name]', qr.el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + + submit: (e) -> + if conf['Auto Watch Reply'] and conf['Thread Watcher'] + if g.REPLY and $('img.favicon').src is Favicon.empty + watcher.watch null, g.THREAD_ID + else + id = $('input[name=resto]', qr.el).value + op = $.id id + if $('img.favicon', op).src is Favicon.empty + watcher.watch op, id + + isQR = @id is 'qr_form' + + inputfile = $('input[type=file]', @) + if inputfile.value and inputfile.files[0].size > $('input[name=MAX_FILE_SIZE]').value + e.preventDefault() if e + if isQR + $('#error', qr.el).textContent = 'Error: File too large.' + else + alert 'Error: File too large.' + + else if isQR + if !e then @submit() + $('#error', qr.el).textContent = '' + qr.autohide.set() if conf['Auto Hide QR'] + qr.sage = /sage/i.test $('input[name=email]', @).value sys: -> if recaptcha = $ '#recaptcha_response_field' #post reporting From 27cea18498f01671fabaec188aeb7d0c73ac36e2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 09:48:52 -0700 Subject: [PATCH 62/80] add -> attach --- 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 6f62a05ed..bb032a6ab 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1240,7 +1240,7 @@ $('#recaptcha_response_field').id = ''; return qr.captcha = []; }, - add: function() { + attach: function() { var file, files; $('#auto', qr.el).checked = true; file = $.el('input', { @@ -1294,7 +1294,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1307,7 +1307,7 @@ $.bind($('#autohide', qr.el), 'click', qr.cb.autohide); $.bind($('a[name=close]', qr.el), 'click', qr.close); $.bind($('form', qr.el), 'submit', qr.submit); - $.bind($('a[name=add]', qr.el), 'click', qr.add); + $.bind($('a[name=attach]', qr.el), 'click', qr.attach); $.bind($('img', qr.el), 'click', Recaptcha.reload); $.bind($('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener); return $.append(d.body, qr.el); diff --git a/script.coffee b/script.coffee index 76b0fa0f6..c0e3e5182 100644 --- a/script.coffee +++ b/script.coffee @@ -978,7 +978,7 @@ qr = $('#recaptcha_response_field').id = '' qr.captcha = [] - add: -> + attach: -> $('#auto', qr.el).checked = true file = $.el 'input', type: 'file', name: 'upfile' files = $ '#files', qr.el @@ -1036,7 +1036,7 @@ qr =
- +
@@ -1050,7 +1050,7 @@ qr = $.bind $('#autohide', qr.el), 'click', qr.cb.autohide $.bind $('a[name=close]', qr.el), 'click', qr.close $.bind $('form', qr.el), 'submit', qr.submit - $.bind $('a[name=add]', qr.el), 'click', qr.add + $.bind $('a[name=attach]', qr.el), 'click', qr.attach $.bind $('img', qr.el), 'click', Recaptcha.reload $.bind $('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener From dbb96e975c5fc00b22efb947f18c3c97533cbd3c Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 09:53:04 -0700 Subject: [PATCH 63/80] #recaptcha_response_field --- 4chan_x.user.js | 8 ++++---- script.coffee | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bb032a6ab..b9fdb93db 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1252,7 +1252,7 @@ }, auto: function() { var captcha, responseField; - responseField = $('input[name=recaptcha_response_field]', qr.el); + responseField = $('#recaptcha_response_field', qr.el); if (!responseField.value && (captcha = qr.captcha.shift())) { $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge; responseField.value = captcha.response; @@ -1294,7 +1294,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1309,7 +1309,7 @@ $.bind($('form', qr.el), 'submit', qr.submit); $.bind($('a[name=attach]', qr.el), 'click', qr.attach); $.bind($('img', qr.el), 'click', Recaptcha.reload); - $.bind($('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener); + $.bind($('#recaptcha_response_field', qr.el), 'keydown', Recaptcha.listener); return $.append(d.body, qr.el); }, message: function(e) { @@ -1320,7 +1320,7 @@ if (data) { data = JSON.parse(data); $.extend($('#error', qr.el), data); - $('input[name=recaptcha_response_field]', qr.el).value = ''; + $('#recaptcha_response_field', qr.el).value = ''; qr.autohide.unset(); if (data.textContent === 'You seem to have mistyped the verification.') { qr.auto(); diff --git a/script.coffee b/script.coffee index c0e3e5182..b9cd29f25 100644 --- a/script.coffee +++ b/script.coffee @@ -985,7 +985,7 @@ qr = $.append files, file auto: -> - responseField = $ 'input[name=recaptcha_response_field]', qr.el + responseField = $ '#recaptcha_response_field', qr.el if !responseField.value and captcha = qr.captcha.shift() $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge responseField.value = captcha.response @@ -1034,7 +1034,7 @@ qr =
- +
@@ -1046,13 +1046,13 @@ qr = qr.refresh() $('textarea', qr.el).value = $('textarea').value - $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() - $.bind $('#autohide', qr.el), 'click', qr.cb.autohide - $.bind $('a[name=close]', qr.el), 'click', qr.close - $.bind $('form', qr.el), 'submit', qr.submit - $.bind $('a[name=attach]', qr.el), 'click', qr.attach - $.bind $('img', qr.el), 'click', Recaptcha.reload - $.bind $('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener + $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() + $.bind $('#autohide', qr.el), 'click', qr.cb.autohide + $.bind $('a[name=close]', qr.el), 'click', qr.close + $.bind $('form', qr.el), 'submit', qr.submit + $.bind $('a[name=attach]', qr.el), 'click', qr.attach + $.bind $('img', qr.el), 'click', Recaptcha.reload + $.bind $('#recaptcha_response_field', qr.el), 'keydown', Recaptcha.listener $.append d.body, qr.el @@ -1064,7 +1064,7 @@ qr = if data # error message data = JSON.parse data $.extend $('#error', qr.el), data - $('input[name=recaptcha_response_field]', qr.el).value = '' + $('#recaptcha_response_field', qr.el).value = '' qr.autohide.unset() if data.textContent is 'You seem to have mistyped the verification.' qr.auto() From 7100f51f7d3e9f643013d2c2f4e10201c897413f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 09:59:35 -0700 Subject: [PATCH 64/80] #recaptcha_challenge_field --- 4chan_x.user.js | 10 +++++----- script.coffee | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b9fdb93db..e26cc636f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1254,7 +1254,7 @@ var captcha, responseField; responseField = $('#recaptcha_response_field', qr.el); if (!responseField.value && (captcha = qr.captcha.shift())) { - $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge; + $('#recaptcha_challenge_field', qr.el).value = captcha.challenge; responseField.value = captcha.response; responseField.nextSibling.textContent = qr.captcha.length; } @@ -1293,8 +1293,8 @@ submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; - challenge = $('input[name=recaptcha_challenge_field]').value; - html = "
Quick Reply X
" + spoiler + "
"; + challenge = $('#recaptcha_challenge_field').value; + html = "
Quick Reply X
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1358,7 +1358,7 @@ }, push: function() { this.nextSibling.textContent = qr.captcha.push({ - challenge: $('input[name=recaptcha_challenge_field]', qr.el).value, + challenge: $('#recaptcha_challenge_field', qr.el).value, response: this.value }); Recaptcha.reload(); @@ -2496,7 +2496,7 @@ } target = e.target; $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; - return $('input[name=recaptcha_challenge_field]', qr.el).value = target.value; + return $('#recaptcha_challenge_field', qr.el).value = target.value; } }; nodeInserted = function(e) { diff --git a/script.coffee b/script.coffee index b9cd29f25..a08391419 100644 --- a/script.coffee +++ b/script.coffee @@ -966,6 +966,9 @@ cooldown = qr.auto() qr = + # remove file + # error handling + # persistent captcha init: -> g.callbacks.push qr.node iframe = $.el 'iframe', @@ -987,7 +990,7 @@ qr = auto: -> responseField = $ '#recaptcha_response_field', qr.el if !responseField.value and captcha = qr.captcha.shift() - $('input[name=recaptcha_challenge_field]', qr.el).value = captcha.challenge + $('#recaptcha_challenge_field', qr.el).value = captcha.challenge responseField.value = captcha.response responseField.nextSibling.textContent = qr.captcha.length qr.submit.call $ 'form', qr.el @@ -1019,7 +1022,7 @@ qr = #FIXME inlined cross-thread quotes THREAD_ID = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', link).id spoiler = if $('.postarea label') then '' else '' - challenge = $('input[name=recaptcha_challenge_field]').value + challenge = $('#recaptcha_challenge_field').value html = "
@@ -1029,7 +1032,7 @@ qr =
- +
#{spoiler}
@@ -1094,7 +1097,7 @@ qr = push: -> @nextSibling.textContent = qr.captcha.push - challenge: $('input[name=recaptcha_challenge_field]', qr.el).value + challenge: $('#recaptcha_challenge_field', qr.el).value response: @value Recaptcha.reload() @value = '' @@ -1894,7 +1897,7 @@ Recaptcha = return unless qr.el {target} = e $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value - $('input[name=recaptcha_challenge_field]', qr.el).value = target.value + $('#recaptcha_challenge_field', qr.el).value = target.value nodeInserted = (e) -> {target} = e From 5eb88f735fdc5f3eceb986c64efb4d80452f4815 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 10:03:52 -0700 Subject: [PATCH 65/80] Recaptcha.reloaded -> qr.captchaNode --- 4chan_x.user.js | 20 ++++++++++---------- script.coffee | 14 ++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e26cc636f..ad0b64992 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1238,6 +1238,7 @@ $.append(d.body, iframe); $.bind(window, 'message', qr.message); $('#recaptcha_response_field').id = ''; + $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); return qr.captcha = []; }, attach: function() { @@ -1270,6 +1271,15 @@ return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0; } }, + captchaNode: function(e) { + var target; + if (!qr.el) { + return; + } + target = e.target; + $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; + return $('#recaptcha_challenge_field', qr.el).value = target.value; + }, cb: { autohide: function(e) { if (this.checked) { @@ -2471,7 +2481,6 @@ el = _ref2[_i]; el.tabIndex = 1; } - $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', Recaptcha.reloaded); return $.bind($('#recaptcha_response_field'), 'keydown', Recaptcha.listener); }, listener: function(e) { @@ -2488,15 +2497,6 @@ }, reload: function() { return window.location = 'javascript:Recaptcha.reload()'; - }, - reloaded: function(e) { - var target; - if (!qr.el) { - return; - } - target = e.target; - $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; - return $('#recaptcha_challenge_field', qr.el).value = target.value; } }; nodeInserted = function(e) { diff --git a/script.coffee b/script.coffee index a08391419..d87a49509 100644 --- a/script.coffee +++ b/script.coffee @@ -979,6 +979,8 @@ qr = #hack - nuke id so it doesn't grab focus when reloading $('#recaptcha_response_field').id = '' + + $.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode qr.captcha = [] attach: -> @@ -1001,6 +1003,12 @@ qr = unset: -> $('#autohide:checked', qr.el)?.click() + captchaNode: (e) -> + return unless qr.el + {target} = e + $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value + $('#recaptcha_challenge_field', qr.el).value = target.value + cb: autohide: (e) -> if @checked @@ -1882,7 +1890,6 @@ Recaptcha = #hack to tab from comment straight to recaptcha for el in $$ '#recaptcha_table a' el.tabIndex = 1 - $.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', Recaptcha.reloaded $.bind $('#recaptcha_response_field'), 'keydown', Recaptcha.listener listener: (e) -> if e.keyCode is 8 and @value is '' # backspace to reload @@ -1893,11 +1900,6 @@ Recaptcha = qr.push.call this reload: -> window.location = 'javascript:Recaptcha.reload()' - reloaded: (e) -> - return unless qr.el - {target} = e - $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value - $('#recaptcha_challenge_field', qr.el).value = target.value nodeInserted = (e) -> {target} = e From 9adfa5f866e87c589225b3515d92d745bea46acb Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 10:07:17 -0700 Subject: [PATCH 66/80] move auto auto post into qr --- 4chan_x.user.js | 19 +++++++++++-------- script.coffee | 11 +++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ad0b64992..e059fec5d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1280,6 +1280,15 @@ $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; return $('#recaptcha_challenge_field', qr.el).value = target.value; }, + captchaKeydown: function(e) { + if (e.keyCode === 13 && cooldown.duration) { + $('#auto', qr.el).checked = true; + if (conf['Auto Hide QR']) { + qr.autohide.set(); + } + return qr.push.call(this); + } + }, cb: { autohide: function(e) { if (this.checked) { @@ -1320,6 +1329,7 @@ $.bind($('a[name=attach]', qr.el), 'click', qr.attach); $.bind($('img', qr.el), 'click', Recaptcha.reload); $.bind($('#recaptcha_response_field', qr.el), 'keydown', Recaptcha.listener); + $.bind($('#recaptcha_response_field', qr.el), 'keydown', qr.captchaKeydown); return $.append(d.body, qr.el); }, message: function(e) { @@ -2485,14 +2495,7 @@ }, listener: function(e) { if (e.keyCode === 8 && this.value === '') { - Recaptcha.reload(); - } - if (e.keyCode === 13 && cooldown.duration) { - $('#auto', qr.el).checked = true; - if (conf['Auto Hide QR']) { - qr.autohide.set(); - } - return qr.push.call(this); + return Recaptcha.reload(); } }, reload: function() { diff --git a/script.coffee b/script.coffee index d87a49509..97198d0eb 100644 --- a/script.coffee +++ b/script.coffee @@ -1009,6 +1009,12 @@ qr = $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value $('#recaptcha_challenge_field', qr.el).value = target.value + captchaKeydown: (e) -> + if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running + $('#auto', qr.el).checked = true + qr.autohide.set() if conf['Auto Hide QR'] + qr.push.call this + cb: autohide: (e) -> if @checked @@ -1064,6 +1070,7 @@ qr = $.bind $('a[name=attach]', qr.el), 'click', qr.attach $.bind $('img', qr.el), 'click', Recaptcha.reload $.bind $('#recaptcha_response_field', qr.el), 'keydown', Recaptcha.listener + $.bind $('#recaptcha_response_field', qr.el), 'keydown', qr.captchaKeydown $.append d.body, qr.el @@ -1894,10 +1901,6 @@ Recaptcha = listener: (e) -> if e.keyCode is 8 and @value is '' # backspace to reload Recaptcha.reload() - if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running - $('#auto', qr.el).checked = true - qr.autohide.set() if conf['Auto Hide QR'] - qr.push.call this reload: -> window.location = 'javascript:Recaptcha.reload()' From 4bb6b4cf88d8dac4be66a69543873d47cdbee871 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 10:37:37 -0700 Subject: [PATCH 67/80] shuffle --- 4chan_x.user.js | 6 +++--- script.coffee | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e059fec5d..62385a572 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1230,16 +1230,16 @@ qr = { init: function() { var iframe; - g.callbacks.push(qr.node); iframe = $.el('iframe', { name: 'iframe', hidden: true }); $.append(d.body, iframe); + g.callbacks.push(qr.node); $.bind(window, 'message', qr.message); - $('#recaptcha_response_field').id = ''; $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); - return qr.captcha = []; + qr.captcha = []; + return $('#recaptcha_response_field').id = ''; }, attach: function() { var file, files; diff --git a/script.coffee b/script.coffee index 97198d0eb..211fb83cd 100644 --- a/script.coffee +++ b/script.coffee @@ -969,20 +969,21 @@ qr = # remove file # error handling # persistent captcha + # code review init: -> g.callbacks.push qr.node + $.bind window, 'message', qr.message + $.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode + qr.captcha = [] + iframe = $.el 'iframe', name: 'iframe' hidden: true $.append d.body, iframe - $.bind window, 'message', qr.message #hack - nuke id so it doesn't grab focus when reloading $('#recaptcha_response_field').id = '' - $.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode - qr.captcha = [] - attach: -> $('#auto', qr.el).checked = true file = $.el 'input', type: 'file', name: 'upfile' From 20242869eb681db9a1772365813c38ce417db847 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 13:51:05 -0700 Subject: [PATCH 68/80] rm qr.cb.autohide --- 4chan_x.user.js | 31 ++++++++++++------------------- script.coffee | 22 +++++++++------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 62385a572..a2d5ea868 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1230,15 +1230,15 @@ qr = { init: function() { var iframe; + g.callbacks.push(qr.node); + $.bind(window, 'message', qr.message); + $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); + qr.captcha = []; iframe = $.el('iframe', { name: 'iframe', hidden: true }); $.append(d.body, iframe); - g.callbacks.push(qr.node); - $.bind(window, 'message', qr.message); - $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); - qr.captcha = []; return $('#recaptcha_response_field').id = ''; }, attach: function() { @@ -1263,12 +1263,10 @@ }, autohide: { set: function() { - var _ref; - return (_ref = $('#autohide:not(:checked)', qr.el)) != null ? _ref.click() : void 0; + return $('#autohide').checked = true; }, unset: function() { - var _ref; - return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0; + return $('#autohide').checked = false; } }, captchaNode: function(e) { @@ -1290,13 +1288,6 @@ } }, cb: { - autohide: function(e) { - if (this.checked) { - return $.addClass(qr.el, 'auto'); - } else { - return $.removeClass(qr.el, 'auto'); - } - }, quote: function(e) { e.preventDefault(); return qr.quote(this); @@ -1313,7 +1304,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('#recaptcha_challenge_field').value; - html = "
Quick Reply X
" + spoiler + "
"; + html = " X
Quick Reply
" + spoiler + "
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1323,8 +1314,7 @@ $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { return e.stopPropagation(); }); - $.bind($('#autohide', qr.el), 'click', qr.cb.autohide); - $.bind($('a[name=close]', qr.el), 'click', qr.close); + $.bind($('#close', qr.el), 'click', qr.close); $.bind($('form', qr.el), 'submit', qr.submit); $.bind($('a[name=attach]', qr.el), 'click', qr.attach); $.bind($('img', qr.el), 'click', Recaptcha.reload); @@ -3002,7 +2992,10 @@ width: 100%;\ height: 120px;\ }\ - #qr.auto:not(:hover) > form {\ + #qr #close, #qr #autohide {\ + float: right;\ + }\ + #qr:not(:hover) > #autohide:checked ~ form {\ height: 0;\ overflow: hidden;\ }\ diff --git a/script.coffee b/script.coffee index 211fb83cd..1d0c32546 100644 --- a/script.coffee +++ b/script.coffee @@ -1000,9 +1000,9 @@ qr = autohide: set: -> - $('#autohide:not(:checked)', qr.el)?.click() + $('#autohide').checked = true unset: -> - $('#autohide:checked', qr.el)?.click() + $('#autohide').checked = false captchaNode: (e) -> return unless qr.el @@ -1017,12 +1017,6 @@ qr = qr.push.call this cb: - autohide: (e) -> - if @checked - $.addClass qr.el, 'auto' - else - $.removeClass qr.el, 'auto' - quote: (e) -> e.preventDefault() qr.quote @ @@ -1039,11 +1033,11 @@ qr = spoiler = if $('.postarea label') then '' else '' challenge = $('#recaptcha_challenge_field').value html = " + X +
Quick Reply - - X
@@ -1065,8 +1059,7 @@ qr = $('textarea', qr.el).value = $('textarea').value $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() - $.bind $('#autohide', qr.el), 'click', qr.cb.autohide - $.bind $('a[name=close]', qr.el), 'click', qr.close + $.bind $('#close', qr.el), 'click', qr.close $.bind $('form', qr.el), 'submit', qr.submit $.bind $('a[name=attach]', qr.el), 'click', qr.attach $.bind $('img', qr.el), 'click', Recaptcha.reload @@ -2392,7 +2385,10 @@ main = width: 100%; height: 120px; } - #qr.auto:not(:hover) > form { + #qr #close, #qr #autohide { + float: right; + } + #qr:not(:hover) > #autohide:checked ~ form { height: 0; overflow: hidden; } From d8d1be587d271bfcd68ffdae48c326b54bf68279 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 13:53:09 -0700 Subject: [PATCH 69/80] context --- 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 a2d5ea868..494468bd1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1263,10 +1263,10 @@ }, autohide: { set: function() { - return $('#autohide').checked = true; + return $('#autohide', qr.el).checked = true; }, unset: function() { - return $('#autohide').checked = false; + return $('#autohide', qr.el).checked = false; } }, captchaNode: function(e) { diff --git a/script.coffee b/script.coffee index 1d0c32546..44c84e3f4 100644 --- a/script.coffee +++ b/script.coffee @@ -1000,9 +1000,9 @@ qr = autohide: set: -> - $('#autohide').checked = true + $('#autohide', qr.el).checked = true unset: -> - $('#autohide').checked = false + $('#autohide', qr.el).checked = false captchaNode: (e) -> return unless qr.el From c6e021c309bd48d1c0fc8e36288e465413eb6788 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 13:56:11 -0700 Subject: [PATCH 70/80] rm qr.autohide --- 4chan_x.user.js | 18 +++++------------- script.coffee | 16 +++++----------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 494468bd1..757ff3d03 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1261,14 +1261,6 @@ } return qr.submit.call($('form', qr.el)); }, - autohide: { - set: function() { - return $('#autohide', qr.el).checked = true; - }, - unset: function() { - return $('#autohide', qr.el).checked = false; - } - }, captchaNode: function(e) { var target; if (!qr.el) { @@ -1282,7 +1274,7 @@ if (e.keyCode === 13 && cooldown.duration) { $('#auto', qr.el).checked = true; if (conf['Auto Hide QR']) { - qr.autohide.set(); + $('#autohide', qr.el).checked = true; } return qr.push.call(this); } @@ -1331,7 +1323,7 @@ data = JSON.parse(data); $.extend($('#error', qr.el), data); $('#recaptcha_response_field', qr.el).value = ''; - qr.autohide.unset(); + $('#autohide', qr.el).checked = false; if (data.textContent === 'You seem to have mistyped the verification.') { qr.auto(); } @@ -1363,7 +1355,7 @@ persist: function() { qr.dialog(); if (conf['Auto Hide QR']) { - return qr.autohide.set(); + return $('#autohide', qr.el).checked = true; } }, push: function() { @@ -1377,7 +1369,7 @@ quote: function(link) { var id, s, selection, selectionID, ta, text, _ref; if (qr.el) { - qr.autohide.unset(); + $('#autohide', qr.el).checked = false; } else { qr.dialog(link); } @@ -1435,7 +1427,7 @@ } $('#error', qr.el).textContent = ''; if (conf['Auto Hide QR']) { - qr.autohide.set(); + $('#autohide', qr.el).checked = true; } return qr.sage = /sage/i.test($('input[name=email]', this).value); } diff --git a/script.coffee b/script.coffee index 44c84e3f4..f91c2f1c4 100644 --- a/script.coffee +++ b/script.coffee @@ -998,12 +998,6 @@ qr = responseField.nextSibling.textContent = qr.captcha.length qr.submit.call $ 'form', qr.el - autohide: - set: -> - $('#autohide', qr.el).checked = true - unset: -> - $('#autohide', qr.el).checked = false - captchaNode: (e) -> return unless qr.el {target} = e @@ -1013,7 +1007,7 @@ qr = captchaKeydown: (e) -> if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running $('#auto', qr.el).checked = true - qr.autohide.set() if conf['Auto Hide QR'] + $('#autohide', qr.el).checked = true if conf['Auto Hide QR'] qr.push.call this cb: @@ -1077,7 +1071,7 @@ qr = data = JSON.parse data $.extend $('#error', qr.el), data $('#recaptcha_response_field', qr.el).value = '' - qr.autohide.unset() + $('#autohide', qr.el).checked = false if data.textContent is 'You seem to have mistyped the verification.' qr.auto() return @@ -1102,7 +1096,7 @@ qr = persist: -> qr.dialog() - qr.autohide.set() if conf['Auto Hide QR'] + $('#autohide', qr.el).checked = true if conf['Auto Hide QR'] push: -> @nextSibling.textContent = qr.captcha.push @@ -1113,7 +1107,7 @@ qr = quote: (link) -> if qr.el - qr.autohide.unset() + $('#autohide', qr.el).checked = false else qr.dialog link @@ -1163,7 +1157,7 @@ qr = else if isQR if !e then @submit() $('#error', qr.el).textContent = '' - qr.autohide.set() if conf['Auto Hide QR'] + $('#autohide', qr.el).checked = true if conf['Auto Hide QR'] qr.sage = /sage/i.test $('input[name=email]', @).value sys: -> From 4ef95615207e6adb8f785495837a27674f2d5ed1 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 14:04:23 -0700 Subject: [PATCH 71/80] move qr.persist into main --- 4chan_x.user.js | 11 ++++------- script.coffee | 9 ++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 757ff3d03..1defcf307 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1352,12 +1352,6 @@ quote = $('a.quotejs:not(:first-child)', root); return $.bind(quote, 'click', qr.cb.quote); }, - persist: function() { - qr.dialog(); - if (conf['Auto Hide QR']) { - return $('#autohide', qr.el).checked = true; - } - }, push: function() { this.nextSibling.textContent = qr.captcha.push({ challenge: $('#recaptcha_challenge_field', qr.el).value, @@ -2808,7 +2802,10 @@ imgPreloading.init(); } if (conf['Quick Reply'] && conf['Persistent QR'] && canPost) { - qr.persist(); + 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 f91c2f1c4..b5b0a4294 100644 --- a/script.coffee +++ b/script.coffee @@ -970,6 +970,7 @@ qr = # error handling # persistent captcha # code review + # rm Recaptcha init: -> g.callbacks.push qr.node $.bind window, 'message', qr.message @@ -1094,10 +1095,6 @@ qr = quote = $ 'a.quotejs:not(:first-child)', root $.bind quote, 'click', qr.cb.quote - persist: -> - qr.dialog() - $('#autohide', qr.el).checked = true if conf['Auto Hide QR'] - push: -> @nextSibling.textContent = qr.captcha.push challenge: $('#recaptcha_challenge_field', qr.el).value @@ -2215,7 +2212,9 @@ main = imgPreloading.init() if conf['Quick Reply'] and conf['Persistent QR'] and canPost - qr.persist() + qr.dialog() + if conf['Auto Hide QR'] + $('#autohide', qr.el).checked = true if conf['Post in Title'] titlePost.init() From 48e3fb74d622a64e3340655ede055101c848d7a7 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 14:18:17 -0700 Subject: [PATCH 72/80] rm qr.cb.quote --- 4chan_x.user.js | 19 ++++++++----------- script.coffee | 18 ++++++++---------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1defcf307..d6eaa7c78 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -883,7 +883,7 @@ qrLink = $("span[id^=nothread] a:not(:first-child)", thread); } if (quote) { - return qr.quote(qrLink); + return qr.quote.call(qrLink); } else { if (!qr.el) { qr.dialog(qrLink); @@ -1279,12 +1279,6 @@ return qr.push.call(this); } }, - cb: { - quote: function(e) { - e.preventDefault(); - return qr.quote(this); - } - }, close: function() { $.rm(qr.el); return qr.el = null; @@ -1350,7 +1344,7 @@ node: function(root) { var quote; quote = $('a.quotejs:not(:first-child)', root); - return $.bind(quote, 'click', qr.cb.quote); + return $.bind(quote, 'click', qr.quote); }, push: function() { this.nextSibling.textContent = qr.captcha.push({ @@ -1360,14 +1354,17 @@ Recaptcha.reload(); return this.value = ''; }, - quote: function(link) { + quote: function(e) { var id, s, selection, selectionID, ta, text, _ref; + if (e) { + e.preventDefault(); + } if (qr.el) { $('#autohide', qr.el).checked = false; } else { - qr.dialog(link); + qr.dialog(this); } - id = link.textContent; + id = this.textContent; text = ">>" + id + "\n"; selection = window.getSelection(); if (s = selection.toString()) { diff --git a/script.coffee b/script.coffee index b5b0a4294..cc84430da 100644 --- a/script.coffee +++ b/script.coffee @@ -631,7 +631,7 @@ keybinds = qrLink = $ "span[id^=nothread] a:not(:first-child)", thread if quote - qr.quote qrLink + qr.quote.call qrLink else unless qr.el qr.dialog qrLink @@ -971,6 +971,7 @@ qr = # persistent captcha # code review # rm Recaptcha + # group captcha init: -> g.callbacks.push qr.node $.bind window, 'message', qr.message @@ -1011,11 +1012,6 @@ qr = $('#autohide', qr.el).checked = true if conf['Auto Hide QR'] qr.push.call this - cb: - quote: (e) -> - e.preventDefault() - qr.quote @ - close: -> $.rm qr.el qr.el = null @@ -1093,7 +1089,7 @@ qr = node: (root) -> quote = $ 'a.quotejs:not(:first-child)', root - $.bind quote, 'click', qr.cb.quote + $.bind quote, 'click', qr.quote push: -> @nextSibling.textContent = qr.captcha.push @@ -1102,13 +1098,15 @@ qr = Recaptcha.reload() @value = '' - quote: (link) -> + quote: (e) -> + e.preventDefault() if e + if qr.el $('#autohide', qr.el).checked = false else - qr.dialog link + qr.dialog @ - id = link.textContent + id = @textContent text = ">>#{id}\n" selection = window.getSelection() From 239bcc25c8af3abc7d9cbdda06268977ee72cb29 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 19:22:28 -0700 Subject: [PATCH 73/80] captcha cached --- 4chan_x.user.js | 8 +++++--- script.coffee | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d6eaa7c78..2fc09467c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1257,7 +1257,7 @@ if (!responseField.value && (captcha = qr.captcha.shift())) { $('#recaptcha_challenge_field', qr.el).value = captcha.challenge; responseField.value = captcha.response; - responseField.nextSibling.textContent = qr.captcha.length; + responseField.nextSibling.textContent = qr.captcha.length + ' captcha cached'; } return qr.submit.call($('form', qr.el)); }, @@ -1290,7 +1290,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('#recaptcha_challenge_field').value; - html = " X
Quick Reply
" + spoiler + "
"; + html = " X
Quick Reply
" + spoiler + "
0 captcha cached
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1347,10 +1347,12 @@ return $.bind(quote, 'click', qr.quote); }, push: function() { - this.nextSibling.textContent = qr.captcha.push({ + var l; + l = qr.captcha.push({ challenge: $('#recaptcha_challenge_field', qr.el).value, response: this.value }); + this.nextSibling.textContent = l + ' captcha cached'; Recaptcha.reload(); return this.value = ''; }, diff --git a/script.coffee b/script.coffee index cc84430da..e08b51d98 100644 --- a/script.coffee +++ b/script.coffee @@ -997,7 +997,7 @@ qr = if !responseField.value and captcha = qr.captcha.shift() $('#recaptcha_challenge_field', qr.el).value = captcha.challenge responseField.value = captcha.response - responseField.nextSibling.textContent = qr.captcha.length + responseField.nextSibling.textContent = qr.captcha.length + ' captcha cached' qr.submit.call $ 'form', qr.el captchaNode: (e) -> @@ -1037,7 +1037,7 @@ qr =
- +
0 captcha cached
@@ -1092,9 +1092,10 @@ qr = $.bind quote, 'click', qr.quote push: -> - @nextSibling.textContent = qr.captcha.push + l = qr.captcha.push challenge: $('#recaptcha_challenge_field', qr.el).value response: @value + @nextSibling.textContent = l + ' captcha cached' Recaptcha.reload() @value = '' From 10f3b8bbb232a3144d061312dcbdd424827fe6d9 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 19:37:15 -0700 Subject: [PATCH 74/80] qr.auto -> qr.autoPost --- 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 2fc09467c..ad9482aeb 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1222,7 +1222,7 @@ submit.value = 'Submit'; } if (qr.el && $('#auto', qr.el).checked) { - return qr.auto(); + return qr.autoPost(); } } } @@ -1251,7 +1251,7 @@ files = $('#files', qr.el); return $.append(files, file); }, - auto: function() { + autoPost: function() { var captcha, responseField; responseField = $('#recaptcha_response_field', qr.el); if (!responseField.value && (captcha = qr.captcha.shift())) { @@ -1319,7 +1319,7 @@ $('#recaptcha_response_field', qr.el).value = ''; $('#autohide', qr.el).checked = false; if (data.textContent === 'You seem to have mistyped the verification.') { - qr.auto(); + qr.autoPost(); } return; } diff --git a/script.coffee b/script.coffee index e08b51d98..84c17a74b 100644 --- a/script.coffee +++ b/script.coffee @@ -963,7 +963,7 @@ cooldown = submit.disabled = false submit.value = 'Submit' if qr.el and $('#auto', qr.el).checked - qr.auto() + qr.autoPost() qr = # remove file @@ -992,7 +992,7 @@ qr = files = $ '#files', qr.el $.append files, file - auto: -> + autoPost: -> responseField = $ '#recaptcha_response_field', qr.el if !responseField.value and captcha = qr.captcha.shift() $('#recaptcha_challenge_field', qr.el).value = captcha.challenge @@ -1070,7 +1070,7 @@ qr = $('#recaptcha_response_field', qr.el).value = '' $('#autohide', qr.el).checked = false if data.textContent is 'You seem to have mistyped the verification.' - qr.auto() + qr.autoPost() return if qr.el From e5d33fadaf4be35a3ee8ef7ae3dff214c113864b Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 19:38:14 -0700 Subject: [PATCH 75/80] prepend files --- 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 ad9482aeb..3c6946530 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1249,7 +1249,7 @@ name: 'upfile' }); files = $('#files', qr.el); - return $.append(files, file); + return $.prepend(files, file); }, autoPost: function() { var captcha, responseField; diff --git a/script.coffee b/script.coffee index 84c17a74b..c51f9b473 100644 --- a/script.coffee +++ b/script.coffee @@ -990,7 +990,7 @@ qr = $('#auto', qr.el).checked = true file = $.el 'input', type: 'file', name: 'upfile' files = $ '#files', qr.el - $.append files, file + $.prepend files, file autoPost: -> responseField = $ '#recaptcha_response_field', qr.el From 7310c2e9d3eb0a53105d51bae374f5774ed6c572 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 20:01:07 -0700 Subject: [PATCH 76/80] remove file --- 4chan_x.user.js | 20 ++++++++++++-------- script.coffee | 12 ++++++++---- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3c6946530..a44f909b4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1242,13 +1242,15 @@ return $('#recaptcha_response_field').id = ''; }, attach: function() { - var file, files; + var fileDiv, files; $('#auto', qr.el).checked = true; - file = $.el('input', { - type: 'file', - name: 'upfile' - }); files = $('#files', qr.el); + fileDiv = $.el('div', { + innerHTML: 'X' + }); + $.bind(fileDiv.lastChild, 'click', (function() { + return $.rm(this.parentNode); + })); return $.prepend(files, file); }, autoPost: function() { @@ -1309,7 +1311,7 @@ return $.append(d.body, qr.el); }, message: function(e) { - var data, duration, file, oldFile; + var data, duration, file, fileDiv, oldFile; Recaptcha.reload(); $('iframe[name=iframe]').src = 'about:blank'; data = e.data; @@ -1324,10 +1326,12 @@ return; } if (qr.el) { - file = $('#files input', qr.el); + fileDiv = $('#files div:last-child', qr.el); if (g.REPLY && (conf['Persistent QR'] || file)) { qr.refresh(); - if (file) { + if (fileDiv) { + $.rm(fileDiv); + file = fileDiv.firstChild; oldFile = $('#qr_form input[type=file]', qr.el); $.replace(oldFile, file); } diff --git a/script.coffee b/script.coffee index c51f9b473..b38a85411 100644 --- a/script.coffee +++ b/script.coffee @@ -969,9 +969,10 @@ qr = # remove file # error handling # persistent captcha - # code review # rm Recaptcha # group captcha + # error too large error should happen on attach + # attaching = persistent qr init: -> g.callbacks.push qr.node $.bind window, 'message', qr.message @@ -988,8 +989,9 @@ qr = attach: -> $('#auto', qr.el).checked = true - file = $.el 'input', type: 'file', name: 'upfile' files = $ '#files', qr.el + fileDiv = $.el 'div', innerHTML: 'X' + $.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode) $.prepend files, file autoPost: -> @@ -1074,10 +1076,12 @@ qr = return if qr.el - file = $ '#files input', qr.el + fileDiv = $ '#files div:last-child', qr.el if g.REPLY and (conf['Persistent QR'] or file) qr.refresh() - if file + if fileDiv + $.rm fileDiv + file = fileDiv.firstChild oldFile = $ '#qr_form input[type=file]', qr.el $.replace oldFile, file else From b6866992fb9e078dcd1cecfb30f9288b3b82ff21 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 20:02:42 -0700 Subject: [PATCH 77/80] derp --- 4chan_x.user.js | 2 +- script.coffee | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a44f909b4..d454767c4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1327,7 +1327,7 @@ } if (qr.el) { fileDiv = $('#files div:last-child', qr.el); - if (g.REPLY && (conf['Persistent QR'] || file)) { + if (g.REPLY && (conf['Persistent QR'] || fileDiv)) { qr.refresh(); if (fileDiv) { $.rm(fileDiv); diff --git a/script.coffee b/script.coffee index b38a85411..7ba4c80f6 100644 --- a/script.coffee +++ b/script.coffee @@ -966,7 +966,6 @@ cooldown = qr.autoPost() qr = - # remove file # error handling # persistent captcha # rm Recaptcha @@ -1077,7 +1076,7 @@ qr = if qr.el fileDiv = $ '#files div:last-child', qr.el - if g.REPLY and (conf['Persistent QR'] or file) + if g.REPLY and (conf['Persistent QR'] or fileDiv) qr.refresh() if fileDiv $.rm fileDiv From 0ea0b43f381cd2ff97b183dd8296635acfc5f2fa Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 20:06:36 -0700 Subject: [PATCH 78/80] qr.push -> qr.captchaPush --- 4chan_x.user.js | 22 +++++++++++----------- script.coffee | 19 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d454767c4..2f319a5ad 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1278,9 +1278,19 @@ if (conf['Auto Hide QR']) { $('#autohide', qr.el).checked = true; } - return qr.push.call(this); + return qr.captchaPush.call(this); } }, + captchaPush: function() { + var l; + l = qr.captcha.push({ + challenge: $('#recaptcha_challenge_field', qr.el).value, + response: this.value + }); + this.nextSibling.textContent = l + ' captcha cached'; + Recaptcha.reload(); + return this.value = ''; + }, close: function() { $.rm(qr.el); return qr.el = null; @@ -1350,16 +1360,6 @@ quote = $('a.quotejs:not(:first-child)', root); return $.bind(quote, 'click', qr.quote); }, - push: function() { - var l; - l = qr.captcha.push({ - challenge: $('#recaptcha_challenge_field', qr.el).value, - response: this.value - }); - this.nextSibling.textContent = l + ' captcha cached'; - Recaptcha.reload(); - return this.value = ''; - }, quote: function(e) { var id, s, selection, selectionID, ta, text, _ref; if (e) { diff --git a/script.coffee b/script.coffee index 7ba4c80f6..9c2ebb627 100644 --- a/script.coffee +++ b/script.coffee @@ -971,7 +971,6 @@ qr = # rm Recaptcha # group captcha # error too large error should happen on attach - # attaching = persistent qr init: -> g.callbacks.push qr.node $.bind window, 'message', qr.message @@ -1011,7 +1010,15 @@ qr = if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running $('#auto', qr.el).checked = true $('#autohide', qr.el).checked = true if conf['Auto Hide QR'] - qr.push.call this + qr.captchaPush.call this + + captchaPush: -> + l = qr.captcha.push + challenge: $('#recaptcha_challenge_field', qr.el).value + response: @value + @nextSibling.textContent = l + ' captcha cached' + Recaptcha.reload() + @value = '' close: -> $.rm qr.el @@ -1094,14 +1101,6 @@ qr = quote = $ 'a.quotejs:not(:first-child)', root $.bind quote, 'click', qr.quote - push: -> - l = qr.captcha.push - challenge: $('#recaptcha_challenge_field', qr.el).value - response: @value - @nextSibling.textContent = l + ' captcha cached' - Recaptcha.reload() - @value = '' - quote: (e) -> e.preventDefault() if e From 2a74af9b3b7d8fab3098bc25e36e3577961829bb Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 20:42:57 -0700 Subject: [PATCH 79/80] attach next file if dup detected --- 4chan_x.user.js | 34 ++++++++++++++++++++++------------ script.coffee | 29 ++++++++++++++++++----------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2f319a5ad..18da7935f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1242,16 +1242,22 @@ return $('#recaptcha_response_field').id = ''; }, attach: function() { - var fileDiv, files; + var fileDiv; $('#auto', qr.el).checked = true; - files = $('#files', qr.el); fileDiv = $.el('div', { innerHTML: 'X' }); $.bind(fileDiv.lastChild, 'click', (function() { return $.rm(this.parentNode); })); - return $.prepend(files, file); + return $.prepend(qr.files, fileDiv); + }, + attachNext: function() { + var file, fileDiv, oldFile; + fileDiv = $.rm(qr.files.lastChild); + file = fileDiv.firstChild; + oldFile = $('#qr_form input[type=file]', qr.el); + return $.replace(oldFile, file); }, autoPost: function() { var captcha, responseField; @@ -1307,6 +1313,7 @@ top: '0px', left: '0px' }, html); + qr.files = $('#files', qr.el); qr.refresh(); $('textarea', qr.el).value = $('textarea').value; $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { @@ -1321,7 +1328,7 @@ return $.append(d.body, qr.el); }, message: function(e) { - var data, duration, file, fileDiv, oldFile; + var data, duration; Recaptcha.reload(); $('iframe[name=iframe]').src = 'about:blank'; data = e.data; @@ -1331,19 +1338,22 @@ $('#recaptcha_response_field', qr.el).value = ''; $('#autohide', qr.el).checked = false; if (data.textContent === 'You seem to have mistyped the verification.') { - qr.autoPost(); + if (qr.captcha.length) { + qr.autoPost(); + } + } else if (data.textContent === 'Error: Duplicate file entry detected.' && qr.files.childElementCount) { + qr.attachNext(); + if (qr.captcha.length) { + qr.autoPost(); + } } return; } if (qr.el) { - fileDiv = $('#files div:last-child', qr.el); - if (g.REPLY && (conf['Persistent QR'] || fileDiv)) { + if (g.REPLY && (conf['Persistent QR'] || qr.files.childElementCount)) { qr.refresh(); - if (fileDiv) { - $.rm(fileDiv); - file = fileDiv.firstChild; - oldFile = $('#qr_form input[type=file]', qr.el); - $.replace(oldFile, file); + if (qr.files.childElementCount) { + qr.attachNext(); } } else { qr.close(); diff --git a/script.coffee b/script.coffee index 9c2ebb627..c59758f06 100644 --- a/script.coffee +++ b/script.coffee @@ -966,10 +966,10 @@ cooldown = qr.autoPost() qr = + # TODO # error handling # persistent captcha # rm Recaptcha - # group captcha # error too large error should happen on attach init: -> g.callbacks.push qr.node @@ -987,10 +987,15 @@ qr = attach: -> $('#auto', qr.el).checked = true - files = $ '#files', qr.el fileDiv = $.el 'div', innerHTML: 'X' $.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode) - $.prepend files, file + $.prepend qr.files, fileDiv + + attachNext: -> + fileDiv = $.rm qr.files.lastChild + file = fileDiv.firstChild + oldFile = $ '#qr_form input[type=file]', qr.el + $.replace oldFile, file autoPost: -> responseField = $ '#recaptcha_response_field', qr.el @@ -1053,6 +1058,7 @@ qr = " qr.el = ui.dialog 'qr', top: '0px', left: '0px', html + qr.files = $ '#files', qr.el qr.refresh() $('textarea', qr.el).value = $('textarea').value @@ -1078,18 +1084,19 @@ qr = $('#recaptcha_response_field', qr.el).value = '' $('#autohide', qr.el).checked = false if data.textContent is 'You seem to have mistyped the verification.' - qr.autoPost() + if qr.captcha.length + qr.autoPost() + else if data.textContent is 'Error: Duplicate file entry detected.' and qr.files.childElementCount + qr.attachNext() + if qr.captcha.length + qr.autoPost() return if qr.el - fileDiv = $ '#files div:last-child', qr.el - if g.REPLY and (conf['Persistent QR'] or fileDiv) + if g.REPLY and (conf['Persistent QR'] or qr.files.childElementCount) qr.refresh() - if fileDiv - $.rm fileDiv - file = fileDiv.firstChild - oldFile = $ '#qr_form input[type=file]', qr.el - $.replace oldFile, file + if qr.files.childElementCount + qr.attachNext() else qr.close() if conf['Cooldown'] From d8f6deb447d958a8f3c6c69e8e8a2941dc37d35f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 20:45:10 -0700 Subject: [PATCH 80/80] attach error message to text --- 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 18da7935f..4cd6e2734 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1342,6 +1342,7 @@ qr.autoPost(); } } else if (data.textContent === 'Error: Duplicate file entry detected.' && qr.files.childElementCount) { + $('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href; qr.attachNext(); if (qr.captcha.length) { qr.autoPost(); diff --git a/script.coffee b/script.coffee index c59758f06..99e5ec540 100644 --- a/script.coffee +++ b/script.coffee @@ -1087,6 +1087,7 @@ qr = if qr.captcha.length qr.autoPost() else if data.textContent is 'Error: Duplicate file entry detected.' and qr.files.childElementCount + $('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href qr.attachNext() if qr.captcha.length qr.autoPost()