diff --git a/4chan_x.user.js b/4chan_x.user.js index 9716b4420..d5489ceb1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3710,17 +3710,18 @@ return Main.callbacks.push(this.node); }, node: function(post) { - var img, src; - if (post.root.hidden || !post.img) { + var gif, img, src; + img = post.img; + if (post.root.hidden || !img) { return; } - src = post.img.parentNode.href; - if (/gif$/.test(src) && !/spoiler/.test(post.img.src)) { - img = $.el('img'); - $.on(img, 'load', function() { - return post.img.src = src; + src = img.parentNode.href; + if (/gif$/.test(src) && !/spoiler/.test(img.src)) { + gif = $.el('img'); + $.on(gif, 'load', function() { + return img.src = src; }); - return img.src = src; + return gif.src = src; } } }; diff --git a/script.coffee b/script.coffee index 9b2cae76f..fb0cf70bb 100644 --- a/script.coffee +++ b/script.coffee @@ -2845,14 +2845,15 @@ AutoGif = return if g.BOARD is 'gif' Main.callbacks.push @node node: (post) -> - return if post.root.hidden or not post.img - src = post.img.parentNode.href - if /gif$/.test(src) and !/spoiler/.test post.img.src - img = $.el 'img' - $.on img, 'load', -> + {img} = post + return if post.root.hidden or not img + src = img.parentNode.href + if /gif$/.test(src) and !/spoiler/.test img.src + gif = $.el 'img' + $.on gif, 'load', -> # Replace the thumbnail once the GIF has finished loading. - post.img.src = src - img.src = src + img.src = src + gif.src = src ImageExpand = init: ->