From 92adcaf28a1ce746d126eaed24d01c7847f6ebba Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 15 Jan 2013 23:28:56 -0800 Subject: [PATCH] ImageExpand.expand: return if pdf --- 4chan_x.user.js | 10 +++++++--- script.coffee | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fb5803d1d..9a665b310 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -5127,20 +5127,24 @@ thumb.nextSibling.hidden = true; return $.rmClass(thumb.parentNode.parentNode.parentNode, 'image_expanded'); }, - expand: function(thumb, url) { + expand: function(thumb, src) { var a, img; if ($.x('ancestor-or-self::*[@hidden]', thumb)) { return; } + a = thumb.parentNode; + src || (src = a.href); + if (/\.pdf$/.test(src)) { + return; + } thumb.hidden = true; $.addClass(thumb.parentNode.parentNode.parentNode, 'image_expanded'); if (img = thumb.nextSibling) { img.hidden = false; return; } - a = thumb.parentNode; img = $.el('img', { - src: url || a.href + src: src }); $.on(img, 'error', ImageExpand.error); return $.add(a, img); diff --git a/script.coffee b/script.coffee index 8f8021a83..7d8759332 100644 --- a/script.coffee +++ b/script.coffee @@ -4144,18 +4144,19 @@ ImageExpand = thumb.nextSibling.hidden = true $.rmClass thumb.parentNode.parentNode.parentNode, 'image_expanded' - expand: (thumb, url) -> + expand: (thumb, src) -> # Do not expand images of hidden/filtered replies, or already expanded pictures. return if $.x 'ancestor-or-self::*[@hidden]', thumb + a = thumb.parentNode + src or= a.href + return if /\.pdf$/.test src thumb.hidden = true $.addClass thumb.parentNode.parentNode.parentNode, 'image_expanded' if img = thumb.nextSibling # Expand already loaded picture img.hidden = false return - a = thumb.parentNode - img = $.el 'img', - src: url or a.href + img = $.el 'img', { src } $.on img, 'error', ImageExpand.error $.add a, img