diff --git a/4chan_x.user.js b/4chan_x.user.js index 9fdfa2328..27179305b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3986,21 +3986,22 @@ } }, preParse: function(node) { - var klass; + var klass, post; klass = node.className; - return { + post = { root: node, el: klass === 'op' ? node : node.firstChild.firstChild.lastChild, "class": klass, - id: $('input', node).name, + id: node.getElementsByTagName('input')[0].name, threadId: g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id, isOP: klass === 'op', isInlined: /\binline\b/.test(klass), - filesize: $('.filesize', node), - img: $('img[md5]', node), + filesize: node.getElementsByClassName('filesize')[0] || false, quotes: node.getElementsByClassName('quotelink'), backlinks: node.getElementsByClassName('backlink') }; + post.img = post.filesize ? node.getElementsByTagName('img')[0] : false; + return post; }, node: function(nodes, notify) { var callback, node, _i, _j, _len, _len2, _ref; diff --git a/script.coffee b/script.coffee index cae6ca284..3833522cd 100644 --- a/script.coffee +++ b/script.coffee @@ -3319,17 +3319,19 @@ Main = preParse: (node) -> klass = node.className - root: node - el: if klass is 'op' then node else node.firstChild.firstChild.lastChild - class: klass - id: $('input', node).name - threadId: g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id - isOP: klass is 'op' - isInlined: /\binline\b/.test klass - filesize: $ '.filesize', node - img: $ 'img[md5]', node - quotes: node.getElementsByClassName 'quotelink' - backlinks: node.getElementsByClassName 'backlink' + post = + root: node + el: if klass is 'op' then node else node.firstChild.firstChild.lastChild + class: klass + id: node.getElementsByTagName('input')[0].name + threadId: g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id + isOP: klass is 'op' + isInlined: /\binline\b/.test klass + filesize: node.getElementsByClassName('filesize')[0] or false + quotes: node.getElementsByClassName 'quotelink' + backlinks: node.getElementsByClassName 'backlink' + post.img = if post.filesize then node.getElementsByTagName('img')[0] else false + post node: (nodes, notify) -> for callback in g.callbacks try