diff --git a/4chan_x.user.js b/4chan_x.user.js index b99c61db4..d96208cfc 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -704,17 +704,17 @@ return text.join(''); }, filename: function(post) { - var file, fileinfo; - fileinfo = post.fileinfo; - if (fileinfo && (file = $('span', fileinfo))) { + var file, fileInfo; + fileInfo = post.fileInfo; + if (fileInfo && (file = $('span', fileInfo))) { return file.title; } return false; }, dimensions: function(post) { - var fileinfo, match; - fileinfo = post.fileinfo; - if (fileinfo && (match = fileinfo.textContent.match(/\d+x\d+/))) { + var fileInfo, match; + fileInfo = post.fileInfo; + if (fileInfo && (match = fileInfo.textContent.match(/\d+x\d+/))) { return match[0]; } return false; @@ -2791,7 +2791,7 @@ link = _ref[_i]; nodes.push($.tn('\u00A0'), link(img)); } - return $.add(post.fileinfo, nodes); + return $.add(post.fileInfo, nodes); } }; @@ -4144,7 +4144,7 @@ } }, preParse: function(node) { - var file, klass, post; + var fileInfo, img, klass, post; klass = node.className; post = { root: node.parentNode, @@ -4154,14 +4154,16 @@ threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1), isInlined: /\binline\b/.test(klass), quotes: node.getElementsByClassName('quotelink'), - backlinks: node.getElementsByClassName('backlink') + backlinks: node.getElementsByClassName('backlink'), + fileInfo: false, + img: false }; - if (file = $('.file', node)) { - post.fileinfo = file.firstElementChild; - post.img = file.lastElementChild.firstElementChild; - } else { - post.fileinfo = false; - post.img = false; + if (fileInfo = $('.fileInfo', node)) { + img = fileInfo.nextElementSibling.firstElementChild; + if (img.alt !== 'File deleted.') { + post.fileInfo = fileInfo; + post.img = img; + } } return post; }, diff --git a/script.coffee b/script.coffee index 791f7ae21..83b3ca41a 100644 --- a/script.coffee +++ b/script.coffee @@ -576,13 +576,13 @@ Filter = text.push if data = nodes.snapshotItem(i).data then data else '\n' text.join '' filename: (post) -> - {fileinfo} = post - if fileinfo and file = $ 'span', fileinfo + {fileInfo} = post + if fileInfo and file = $ 'span', fileInfo return file.title false dimensions: (post) -> - {fileinfo} = post - if fileinfo and match = fileinfo.textContent.match /\d+x\d+/ + {fileInfo} = post + if fileInfo and match = fileInfo.textContent.match /\d+x\d+/ return match[0] false filesize: (post) -> @@ -2211,7 +2211,7 @@ Sauce = for link in Sauce.links # \u00A0 is nbsp nodes.push $.tn('\u00A0'), link img - $.add post.fileinfo, nodes + $.add post.fileInfo, nodes RevealSpoilers = init: -> @@ -3200,12 +3200,13 @@ Main = isInlined: /\binline\b/.test klass quotes: node.getElementsByClassName 'quotelink' backlinks: node.getElementsByClassName 'backlink' - if file = $ '.file', node - post.fileinfo = file.firstElementChild - post.img = file.lastElementChild.firstElementChild - else - post.fileinfo = false - post.img = false + fileInfo: false + img: false + if fileInfo = $ '.fileInfo', node + img = fileInfo.nextElementSibling.firstElementChild + if img.alt isnt 'File deleted.' + post.fileInfo = fileInfo + post.img = img post node: (nodes, notify) -> for callback in Main.callbacks