From dea5bebe7dfac7c6784e9b7ed0ef3560fce0e4d4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 29 Sep 2011 17:05:59 -0700 Subject: [PATCH 1/5] reset --- 4chan_x.user.js | 20 +++++++++++--------- script.coffee | 16 +++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fd728ae0c..aba59d483 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1586,17 +1586,13 @@ } }, dialog: function(text, tid) { - var c, l, m, qr, ta; + var l, qr, ta; if (text == null) { text = ''; } tid || (tid = g.THREAD_ID || ''); QR.qr = qr = ui.dialog('qr', 'top: 0; right: 0;', " X
" + (g.REPLY ? "" : '') + " " + QR.spoiler + "
"); - c = d.cookie; - $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; - $('textarea', qr).value = text; + QR.reset(); if (conf['Cooldown']) { QR.cooldown(); } @@ -1697,13 +1693,19 @@ } }, reset: function() { - var _ref; + var c, m, qr, _ref; + qr = QR.qr; + c = d.cookie; + $('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + $('[name=pwd]', qr).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; + $('[name=sub]', qr).value = ''; if (!conf['Remember Spoiler']) { - if ((_ref = $('[name=spoiler]', QR.qr)) != null) { + if ((_ref = $('[name=spoiler]', qr)) != null) { _ref.checked = false; } } - return $('textarea', QR.qr).value = ''; + return $('textarea', qr).value = ''; }, submit: function(e) { var captcha, challenge, el, id, input, op, qr, response; diff --git a/script.coffee b/script.coffee index 9abc1e96c..fc0874b33 100644 --- a/script.coffee +++ b/script.coffee @@ -1182,11 +1182,7 @@ QR = " #XXX use dom methods to set values instead of injecting raw user input into your html -_-; - c = d.cookie - $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' - $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value - $('textarea', qr).value = text + QR.reset() QR.cooldown() if conf['Cooldown'] QR.foo() $.bind $('.close', qr), 'click', QR.close @@ -1261,8 +1257,14 @@ QR = $.set "cooldown/#{g.BOARD}", cooldown QR.cooldown() reset: -> - $('[name=spoiler]', QR.qr)?.checked = false unless conf['Remember Spoiler'] - $('textarea', QR.qr).value = '' + {qr} = QR + c = d.cookie + $('[name=name]', qr).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=email]', qr).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + $('[name=pwd]', qr).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + $('[name=sub]', qr).value = '' + $('[name=spoiler]', qr)?.checked = false unless conf['Remember Spoiler'] + $('textarea', qr).value = '' submit: (e) -> {qr} = QR #XXX e is undefined if method is called explicitly, eg, from auto posting From c1682ab23cb92eea25377d095899799cbd1fccae Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 29 Sep 2011 17:06:46 -0700 Subject: [PATCH 2/5] fix --- 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 aba59d483..e9db8594b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1604,6 +1604,7 @@ QR.stats(); $.add(d.body, qr); ta = $('textarea', qr); + ta.value = text; l = text.length; ta.setSelectionRange(l, l); return ta.focus(); diff --git a/script.coffee b/script.coffee index fc0874b33..d77172822 100644 --- a/script.coffee +++ b/script.coffee @@ -1192,6 +1192,7 @@ QR = QR.stats() $.add d.body, qr ta = $ 'textarea', qr + ta.value = text l = text.length ta.setSelectionRange l, l ta.focus() From 3983c2b96b77a1e3268c2d38884678bc2065608f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Sep 2011 21:27:26 +0200 Subject: [PATCH 3/5] Don't add filtered/hidden posts to the unread count. --- 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 e9db8594b..d91522266 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2684,7 +2684,7 @@ return g.callbacks.push(unread.node); }, node: function(root) { - if (root.className) { + if (root.hidden || root.className) { return; } unread.replies.push(root); diff --git a/script.coffee b/script.coffee index d77172822..87b669c0e 100644 --- a/script.coffee +++ b/script.coffee @@ -1959,7 +1959,7 @@ unread = g.callbacks.push unread.node node: (root) -> - return if root.className + return if root.hidden or root.className unread.replies.push root unread.updateTitle() Favicon.update() From b2db0242fdeca98888f7f7a2023eb89b539a1d11 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Sep 2011 21:25:13 +0200 Subject: [PATCH 4/5] Shorter selectors. --- 4chan_x.user.js | 26 +++++++++++++------------- script.coffee | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d91522266..ae2a3d8f6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -632,7 +632,7 @@ expandComment = { init: function() { var a, _i, _len, _ref, _results; - _ref = $$('span.abbr a'); + _ref = $$('.abbr a'); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; @@ -696,7 +696,7 @@ expandThread = { init: function() { var a, span, _i, _len, _ref, _results; - _ref = $$('span.omittedposts'); + _ref = $$('.omittedposts'); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { span = _ref[_i]; @@ -803,7 +803,7 @@ init: function() { return g.callbacks.push(function(root) { var a, dd, id, reply; - if (!(dd = $('td.doubledash', root))) { + if (!(dd = $('.doubledash', root))) { return; } dd.className = 'replyhider'; @@ -845,8 +845,8 @@ table = reply.parentNode.parentNode.parentNode; table.hidden = true; if (conf['Show Stubs']) { - name = $('span.commentpostername', reply).textContent; - trip = ((_ref = $('span.postertrip', reply)) != null ? _ref.textContent : void 0) || ''; + name = $('.commentpostername', reply).textContent; + trip = ((_ref = $('.postertrip', reply)) != null ? _ref.textContent : void 0) || ''; a = $.el('a', { textContent: "[ + ] " + name + " " + trip }); @@ -1884,8 +1884,8 @@ } num += $$('table', thread).length; text = num === 1 ? "1 reply" : "" + num + " replies"; - name = $('span.postername', thread).textContent; - trip = ((_ref = $('span.postername + span.postertrip', thread)) != null ? _ref.textContent : void 0) || ''; + name = $('.postername', thread).textContent; + trip = ((_ref = $('.postername + .postertrip', thread)) != null ? _ref.textContent : void 0) || ''; a = $.el('a', { textContent: "[ + ] " + name + trip + " (" + text + ")" }); @@ -2166,9 +2166,9 @@ init: function() { return g.callbacks.push(function(root) { var name, trip; - name = $('span.commentpostername, span.postername', root); + name = $('.commentpostername, .postername', root); name.textContent = 'Anonymous'; - if (trip = $('span.postertrip', root)) { + if (trip = $('.postertrip', root)) { if (trip.parentNode.nodeName === 'A') { return $.rm(trip.parentNode); } else { @@ -2208,7 +2208,7 @@ if (root.className === 'inline') { return; } - if (span = $('span.filesize', root)) { + if (span = $('.filesize', root)) { suffix = $('a', span).href; _ref = sauce.prefixes; _results = []; @@ -2339,11 +2339,11 @@ }; getTitle = function(thread) { var el, span; - el = $('span.filetitle', thread); + el = $('.filetitle', thread); if (!el.textContent) { el = $('blockquote', thread); if (!el.textContent) { - el = $('span.postername', thread); + el = $('.postername', thread); } } span = $.el('span', { @@ -2944,7 +2944,7 @@ src: a.href }); if (a.parentNode.className !== 'op') { - filesize = $('span.filesize', a.parentNode); + filesize = $('.filesize', a.parentNode); _ref = filesize.textContent.match(/(\d+)x/), _ = _ref[0], max = _ref[1]; img.style.maxWidth = "-moz-calc(" + max + "px)"; } diff --git a/script.coffee b/script.coffee index 87b669c0e..8f48a06a5 100644 --- a/script.coffee +++ b/script.coffee @@ -439,7 +439,7 @@ filter = expandComment = init: -> - for a in $$ 'span.abbr a' + for a in $$ '.abbr a' $.bind a, 'click', expandComment.expand expand: (e) -> e.preventDefault() @@ -480,7 +480,7 @@ expandComment = expandThread = init: -> - for span in $$ 'span.omittedposts' + for span in $$ '.omittedposts' a = $.el 'a', textContent: "+ #{span.textContent}" className: 'omittedposts' @@ -555,7 +555,7 @@ expandThread = replyHiding = init: -> g.callbacks.push (root) -> - return unless dd = $ 'td.doubledash', root + return unless dd = $ '.doubledash', root dd.className = 'replyhider' a = $.el 'a', textContent: '[ - ]' @@ -591,8 +591,8 @@ replyHiding = table.hidden = true if conf['Show Stubs'] - name = $('span.commentpostername', reply).textContent - trip = $('span.postertrip', reply)?.textContent or '' + name = $('.commentpostername', reply).textContent + trip = $('.postertrip', reply)?.textContent or '' a = $.el 'a', textContent: "[ + ] #{name} #{trip}" $.bind a, 'click', replyHiding.cb.show @@ -1399,8 +1399,8 @@ threadHiding = num = 0 num += $$('table', thread).length text = if num is 1 then "1 reply" else "#{num} replies" - name = $('span.postername', thread).textContent - trip = $('span.postername + span.postertrip', thread)?.textContent or '' + name = $('.postername', thread).textContent + trip = $('.postername + .postertrip', thread)?.textContent or '' a = $.el 'a', textContent: "[ + ] #{name}#{trip} (#{text})" @@ -1638,9 +1638,9 @@ watcher = anonymize = init: -> g.callbacks.push (root) -> - name = $ 'span.commentpostername, span.postername', root + name = $ '.commentpostername, .postername', root name.textContent = 'Anonymous' - if trip = $ 'span.postertrip', root + if trip = $ '.postertrip', root if trip.parentNode.nodeName is 'A' $.rm trip.parentNode else @@ -1652,7 +1652,7 @@ sauce = sauce.names = (prefix.match(/(\w+)\./)[1] for prefix in sauce.prefixes) g.callbacks.push (root) -> return if root.className is 'inline' - if span = $ 'span.filesize', root + if span = $ '.filesize', root suffix = $('a', span).href for prefix, i in sauce.prefixes link = $.el 'a', @@ -1737,11 +1737,11 @@ Time = y: -> Time.date.getFullYear() - 2000 getTitle = (thread) -> - el = $ 'span.filetitle', thread + el = $ '.filetitle', thread if not el.textContent el = $ 'blockquote', thread if not el.textContent - el = $ 'span.postername', thread + el = $ '.postername', thread span = $.el 'span', innerHTML: el.innerHTML.replace /
/g, ' ' "/#{g.BOARD}/ - #{span.textContent}" @@ -2115,7 +2115,7 @@ imgExpand = img = $.el 'img', src: a.href unless a.parentNode.className is 'op' - filesize = $ 'span.filesize', a.parentNode + filesize = $ '.filesize', a.parentNode [_, max] = filesize.textContent.match /(\d+)x/ img.style.maxWidth = "-moz-calc(#{max}px)" $.bind img, 'error', imgExpand.error From 2dacb2c8cbcb0743fff66147ba435b7666c17194 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Sep 2011 18:28:05 +0200 Subject: [PATCH 5/5] Hide asap. --- 4chan_x.user.js | 12 ++++++------ script.coffee | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ae2a3d8f6..6aecf61b8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3069,6 +3069,9 @@ if (conf['Filter']) { filter.init(); } + if (conf['Reply Hiding']) { + replyHiding.init(); + } if (conf['Image Expansion']) { imgExpand.init(); } @@ -3090,9 +3093,6 @@ if (conf['Image Hover']) { imgHover.init(); } - if (conf['Reply Hiding']) { - replyHiding.init(); - } if (conf['Quick Reply']) { QR.init(); } @@ -3137,12 +3137,12 @@ nav.init(); } } else { - if (conf['Index Navigation']) { - nav.init(); - } if (conf['Thread Hiding']) { threadHiding.init(); } + if (conf['Index Navigation']) { + nav.init(); + } if (conf['Thread Expansion']) { expandThread.init(); } diff --git a/script.coffee b/script.coffee index 8f48a06a5..c9ec262b9 100644 --- a/script.coffee +++ b/script.coffee @@ -2285,6 +2285,9 @@ Main = if conf['Filter'] filter.init() + if conf['Reply Hiding'] + replyHiding.init() + if conf['Image Expansion'] imgExpand.init() @@ -2306,9 +2309,6 @@ Main = if conf['Image Hover'] imgHover.init() - if conf['Reply Hiding'] - replyHiding.init() - if conf['Quick Reply'] QR.init() @@ -2353,12 +2353,12 @@ Main = nav.init() else #not reply - if conf['Index Navigation'] - nav.init() - if conf['Thread Hiding'] threadHiding.init() + if conf['Index Navigation'] + nav.init() + if conf['Thread Expansion'] expandThread.init()