From 07ada393420b84558a28a5d39ccc6bc690505ae0 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 14 Jun 2012 22:04:35 +0200 Subject: [PATCH] Fix file preParsing for /f/. Close #445 --- 4chan_x.user.js | 11 ++++------- script.coffee | 13 ++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 68c5ef589..38c52826f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4302,7 +4302,7 @@ } }, preParse: function(node) { - var el, fileInfo, img, post, rootClass; + var el, img, post, rootClass; rootClass = node.className; el = $('.post', node); post = { @@ -4319,12 +4319,9 @@ fileInfo: false, img: false }; - if (fileInfo = $('.fileInfo', el)) { - img = fileInfo.nextElementSibling.firstElementChild; - if (img.alt !== 'File deleted.') { - post.fileInfo = fileInfo; - post.img = img; - } + if (img = $('img[data-md5]', el)) { + post.fileInfo = img.parentNode.previousElementSibling; + post.img = img; } Main.prettify(post.blockquote); return post; diff --git a/script.coffee b/script.coffee index 1f4d78d9d..de035fa7b 100644 --- a/script.coffee +++ b/script.coffee @@ -1487,7 +1487,6 @@ QR = # save selected reply's data for name in ['name', 'email', 'sub', 'com'] # The input event replaces keyup, change and paste events. - # XXX Does Opera support the `input` event? $.on $("[name=#{name}]", QR.el), 'input', -> QR.selected[@name] = @value # Disable auto-posting if you're typing in the first reply @@ -2148,7 +2147,7 @@ Sauce = @links = [] for link in Conf['sauces'].split '\n' continue if link[0] is '#' - # .trim() is there to fix Opera reading two different line breaks. + # XXX .trim() is there to fix Opera reading two different line breaks. @links.push @createSauceLink link.trim() return unless @links.length Main.callbacks.push @node @@ -3292,11 +3291,11 @@ Main = backlinks: el.getElementsByClassName 'backlink' fileInfo: false img: false - if fileInfo = $ '.fileInfo', el - img = fileInfo.nextElementSibling.firstElementChild - if img.alt isnt 'File deleted.' - post.fileInfo = fileInfo - post.img = img + if img = $ 'img[data-md5]', el + # Make sure to not add deleted images, + # those do not have a data-md5 attribute. + post.fileInfo = img.parentNode.previousElementSibling + post.img = img Main.prettify post.blockquote post node: (nodes, notify) ->