From b1f257fbd9afc19e24606c1b4057547747f6aeeb Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 18 Feb 2012 01:58:11 +0100 Subject: [PATCH] Few small optimizations. --- 4chan_x.user.js | 22 +++++++++------------- script.coffee | 17 +++++++---------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 783270ed1..7a743b9fd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -634,7 +634,7 @@ expandComment = { init: function() { var a, _i, _len, _ref, _results; - _ref = $$('.abbr a'); + _ref = $$('.abbr > a'); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; @@ -837,22 +837,18 @@ return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); }, hideHide: function(reply) { - var a, div, name, table, trip, _ref; + var div, name, table, trip, _ref; table = reply.parentNode.parentNode.parentNode; if (table.hidden) return; table.hidden = true; if (conf['Show Stubs']) { name = $('.commentpostername', reply).textContent; trip = ((_ref = $('.postertrip', reply)) != null ? _ref.textContent : void 0) || ''; - a = $.el('a', { - innerHTML: "[ + ] " + name + " " + trip, - href: 'javascript:;' - }); - $.on(a, 'click', replyHiding.cb.show); div = $.el('div', { - className: 'stub' + className: 'stub', + innerHTML: "[ + ] " + name + " " + trip + "" }); - $.add(div, a); + $.on($('a', div), 'click', replyHiding.cb.show); return $.before(table, div); } }, @@ -2542,7 +2538,7 @@ html = '
Thread Watcher
'; watcher.dialog = ui.dialog('watcher', 'top: 50px; left: 0px;', html); $.add(d.body, watcher.dialog); - inputs = $$('.op input'); + inputs = $$('.op > input'); for (_i = 0, _len = inputs.length; _i < _len; _i++) { input = inputs[_i]; favicon = $.el('img', { @@ -2586,7 +2582,7 @@ } $.add(watcher.dialog, nodes); watchedBoard = watched[g.BOARD] || {}; - _ref3 = $$('img.favicon'); + _ref3 = $$('.favicon'); for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { favicon = _ref3[_j]; id = favicon.nextSibling.name; @@ -2973,7 +2969,7 @@ op = threading.op($('body > form', body).firstChild); html = op.innerHTML; } else { - _ref = $$('td.reply', body); + _ref = $$('.reply', body); for (_i = 0, _len = _ref.length; _i < _len; _i++) { reply = _ref[_i]; if (reply.id === id) { @@ -3073,7 +3069,7 @@ op = threading.op($('body > form', body).firstChild); html = op.innerHTML; } else { - _ref = $$('td.reply', body); + _ref = $$('.reply', body); for (_i = 0, _len = _ref.length; _i < _len; _i++) { reply = _ref[_i]; if (reply.id === id) { diff --git a/script.coffee b/script.coffee index 639ac87dd..beef4625c 100644 --- a/script.coffee +++ b/script.coffee @@ -473,7 +473,7 @@ strikethroughQuotes = expandComment = init: -> - for a in $$ '.abbr a' + for a in $$ '.abbr > a' $.on a, 'click', expandComment.expand expand: (e) -> e.preventDefault() @@ -630,14 +630,11 @@ replyHiding = if conf['Show Stubs'] name = $('.commentpostername', reply).textContent trip = $('.postertrip', reply)?.textContent or '' - a = $.el 'a', - innerHTML: "[ + ] #{name} #{trip}" - href: 'javascript:;' - $.on a, 'click', replyHiding.cb.show div = $.el 'div', className: 'stub' - $.add div, a + innerHTML: "[ + ] #{name} #{trip}" + $.on $('a', div), 'click', replyHiding.cb.show $.before table, div show: (table) -> @@ -2028,7 +2025,7 @@ watcher = $.add d.body, watcher.dialog #add watch buttons - inputs = $$ '.op input' + inputs = $$ '.op > input' for input in inputs favicon = $.el 'img', className: 'favicon' @@ -2065,7 +2062,7 @@ watcher = $.add watcher.dialog, nodes watchedBoard = watched[g.BOARD] or {} - for favicon in $$ 'img.favicon' + for favicon in $$ '.favicon' id = favicon.nextSibling.name if id of watchedBoard favicon.src = Favicon.default @@ -2352,7 +2349,7 @@ quoteInline = op = threading.op $('body > form', body).firstChild html = op.innerHTML else - for reply in $$ 'td.reply', body + for reply in $$ '.reply', body if reply.id == id html = reply.innerHTML break @@ -2424,7 +2421,7 @@ quotePreview = op = threading.op $('body > form', body).firstChild html = op.innerHTML else - for reply in $$ 'td.reply', body + for reply in $$ '.reply', body if reply.id == id html = reply.innerHTML break