From b33e25ac76b68a2d4debcb9a3110b700e3a0ea15 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 10 Jul 2011 20:57:13 -0700 Subject: [PATCH] only one thumb per root --- 4chan_x.user.js | 30 +++++++++++------------------- script.coffee | 16 +++++++--------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 71e939131..d00cf94bf 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2482,32 +2482,24 @@ imgPreloading = { init: function() { return g.callbacks.push(function(root) { - var el, parent, thumb, thumbs, _i, _len, _results; - thumbs = $$('img[md5]', root); - _results = []; - for (_i = 0, _len = thumbs.length; _i < _len; _i++) { - thumb = thumbs[_i]; - parent = thumb.parentNode; - _results.push(el = $.el('img', { - src: parent.href - })); - } - return _results; + var el, src, thumb; + thumb = $('img[md5]', root); + src = thumb.parentNode.href; + return el = $.el('img', { + src: src + }); }); } }; imgGif = { init: function() { return g.callbacks.push(function(root) { - var src, thumb, thumbs, _i, _len, _results; - thumbs = $$('img[md5]', root); - _results = []; - for (_i = 0, _len = thumbs.length; _i < _len; _i++) { - thumb = thumbs[_i]; - src = thumb.parentNode.href; - _results.push(/gif$/.test(src) ? thumb.src = src : void 0); + var src, thumb; + thumb = $('img[md5]', root); + src = thumb.parentNode.href; + if (/gif$/.test(src)) { + return thumb.src = src; } - return _results; }); } }; diff --git a/script.coffee b/script.coffee index 86a0d0024..c56c8eb32 100644 --- a/script.coffee +++ b/script.coffee @@ -1877,19 +1877,17 @@ imageHover = imgPreloading = init: -> g.callbacks.push (root) -> - thumbs = $$ 'img[md5]', root - for thumb in thumbs - parent = thumb.parentNode - el = $.el 'img', src: parent.href + thumb = $ 'img[md5]', root + src = thumb.parentNode.href + el = $.el 'img', { src } imgGif = init: -> g.callbacks.push (root) -> - thumbs = $$ 'img[md5]', root - for thumb in thumbs - src = thumb.parentNode.href - if /gif$/.test src - thumb.src = src + thumb = $ 'img[md5]', root + src = thumb.parentNode.href + if /gif$/.test src + thumb.src = src imgExpand = init: ->